From e16cfe56738141144b3fa4e353a77822bbf7f931 Mon Sep 17 00:00:00 2001 From: Mick Date: Sun, 7 Jan 2024 22:04:14 +0000 Subject: [PATCH] Add diagnostics log --- .../sagemcom_fast/diagnostics.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 custom_components/sagemcom_fast/diagnostics.py diff --git a/custom_components/sagemcom_fast/diagnostics.py b/custom_components/sagemcom_fast/diagnostics.py new file mode 100644 index 0000000..83a2e5d --- /dev/null +++ b/custom_components/sagemcom_fast/diagnostics.py @@ -0,0 +1,33 @@ +"""Provides diagnostics for Overkiz.""" +from __future__ import annotations + +from typing import Any + +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant + +from . import HomeAssistantSagemcomFastData +from .const import DOMAIN, LOGGER + + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, entry: ConfigEntry +) -> dict[str, Any]: + """Return diagnostics for a config entry.""" + entry_data: HomeAssistantSagemcomFastData = hass.data[DOMAIN][entry.entry_id] + client = entry_data.coordinator.client + + full_dump = None + try: + await client.login() + full_dump = await client.get_value_by_xpath("*") + except Exception as exception: # pylint: disable=broad-except + LOGGER.exception(exception) + + return False + finally: + await client.logout() + + data = {"raw": full_dump} + + return data