Skip to content

Commit

Permalink
Add errors to diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Mar 29, 2024
1 parent 3ef9271 commit ea0007f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions custom_components/yandex_station/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

async def async_get_config_entry_diagnostics(hass: HomeAssistant, entry: ConfigEntry):
quasar: YandexQuasar = hass.data[DOMAIN][entry.unique_id]
return {"devices": quasar.devices}
return {"devices": quasar.devices, "errors": get_errors(hass)}


async def async_get_device_diagnostics(
Expand All @@ -22,4 +22,15 @@ async def async_get_device_diagnostics(
for device in quasar.devices
if device["id"] == did or device.get("quasar_info", {}).get("device_id") == did
)
return {"device": device}
return {"device": device, "errors": get_errors(hass)}


def get_errors(hass: HomeAssistant) -> list | str:
try:
return [
entry.to_dict()
for key, entry in hass.data["system_log"].records.items()
if DOMAIN in str(key)
]
except Exception as e:
return repr(e)

0 comments on commit ea0007f

Please sign in to comment.