From 09a85d2a5df5a452223ece6f86434f8b5e3fcce8 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sat, 12 Mar 2022 05:27:08 +0100 Subject: [PATCH] Add basic rfxtrx diagnostics (#67671) * Add basic rfxtrx diagnostics * Skip diagnostics for coverage --- .coveragerc | 1 + homeassistant/components/rfxtrx/__init__.py | 3 +-- homeassistant/components/rfxtrx/const.py | 2 ++ .../components/rfxtrx/diagnostics.py | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 homeassistant/components/rfxtrx/diagnostics.py diff --git a/.coveragerc b/.coveragerc index f48943388c3..95856947fb6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -960,6 +960,7 @@ omit = homeassistant/components/remote_rpi_gpio/* homeassistant/components/rest/notify.py homeassistant/components/rest/switch.py + homeassistant/components/rfxtrx/diagnostics.py homeassistant/components/ridwell/__init__.py homeassistant/components/ridwell/sensor.py homeassistant/components/ridwell/switch.py diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index d2afda81f9f..ba4cb9eb226 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -42,12 +42,11 @@ from .const import ( CONF_PROTOCOLS, DATA_RFXOBJECT, DEVICE_PACKET_TYPE_LIGHTING4, + DOMAIN, EVENT_RFXTRX_EVENT, SERVICE_SEND, ) -DOMAIN = "rfxtrx" - DEFAULT_OFF_DELAY = 2.0 SIGNAL_EVENT = f"{DOMAIN}_event" diff --git a/homeassistant/components/rfxtrx/const.py b/homeassistant/components/rfxtrx/const.py index 529289090a6..7a6e333d3db 100644 --- a/homeassistant/components/rfxtrx/const.py +++ b/homeassistant/components/rfxtrx/const.py @@ -44,3 +44,5 @@ DEVICE_PACKET_TYPE_LIGHTING4 = 0x13 EVENT_RFXTRX_EVENT = "rfxtrx_event" DATA_RFXOBJECT = "rfxobject" + +DOMAIN = "rfxtrx" diff --git a/homeassistant/components/rfxtrx/diagnostics.py b/homeassistant/components/rfxtrx/diagnostics.py new file mode 100644 index 00000000000..bc2fae2452d --- /dev/null +++ b/homeassistant/components/rfxtrx/diagnostics.py @@ -0,0 +1,19 @@ +"""Diagnostics support for RFXCOM RFXtrx.""" +from __future__ import annotations + +from typing import Any + +from homeassistant.components.diagnostics import async_redact_data +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant + +TO_REDACT = {"host"} + + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, entry: ConfigEntry +) -> dict[str, Any]: + """Return diagnostics for a config entry.""" + return { + "entry": async_redact_data(entry.as_dict(), TO_REDACT), + }