From b8e6599ff64fdbe8eb0368460f323b11e0b7e1e6 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Fri, 30 Aug 2024 11:16:34 +0000 Subject: [PATCH 1/2] feat: add diagnostics --- custom_components/midea_ac_lan/diagnostics.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 custom_components/midea_ac_lan/diagnostics.py diff --git a/custom_components/midea_ac_lan/diagnostics.py b/custom_components/midea_ac_lan/diagnostics.py new file mode 100644 index 0000000..5bef59b --- /dev/null +++ b/custom_components/midea_ac_lan/diagnostics.py @@ -0,0 +1,32 @@ +"""Diagnostics support for Midea AC LAN.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +from homeassistant.components.diagnostics import async_redact_data +from homeassistant.const import ( + CONF_TOKEN, +) + +if TYPE_CHECKING: + from homeassistant.config_entries import ConfigEntry + from homeassistant.core import HomeAssistant + +from .const import CONF_KEY + +TO_REDACT = {CONF_TOKEN, CONF_KEY} + + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, # noqa: ARG001 + entry: ConfigEntry, +) -> dict[str, Any]: + """Return diagnostics for a config entry. + + Returns + ------- + Dictiory of config + + """ + return {"entry": async_redact_data(entry.as_dict(), TO_REDACT)} From 1a5bc876f9ce63a1387b4ffbb7f8eed91cd4270a Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Fri, 30 Aug 2024 11:17:27 +0000 Subject: [PATCH 2/2] chore: typo --- custom_components/midea_ac_lan/diagnostics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/midea_ac_lan/diagnostics.py b/custom_components/midea_ac_lan/diagnostics.py index 5bef59b..3ecd6f3 100644 --- a/custom_components/midea_ac_lan/diagnostics.py +++ b/custom_components/midea_ac_lan/diagnostics.py @@ -26,7 +26,7 @@ async def async_get_config_entry_diagnostics( Returns ------- - Dictiory of config + Dictionary of config """ return {"entry": async_redact_data(entry.as_dict(), TO_REDACT)}