Skip to content

Commit

Permalink
Add diagnostics log
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl committed Jan 7, 2024
1 parent 0d92508 commit e16cfe5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions custom_components/sagemcom_fast/diagnostics.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e16cfe5

Please sign in to comment.