From 1d814a5789e3ba69a88f5f3781970eb1921a0e20 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Sun, 25 Feb 2024 11:14:22 +0100 Subject: [PATCH] Add integration diagnostics, enabled the download of the raw data provided by pymyenergi * custom_components/myenergi/diagnostics.py: Added. --- custom_components/myenergi/diagnostics.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 custom_components/myenergi/diagnostics.py diff --git a/custom_components/myenergi/diagnostics.py b/custom_components/myenergi/diagnostics.py new file mode 100644 index 0000000..4a59ae2 --- /dev/null +++ b/custom_components/myenergi/diagnostics.py @@ -0,0 +1,26 @@ +"""Diagnostics support for Daikin Diagnostics.""" +from __future__ import annotations +from typing import Any + +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant +from homeassistant.helpers.device_registry import DeviceEntry + +from pymyenergi.client import MyenergiClient +from pymyenergi.connection import Connection + +from .const import DOMAIN + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, entry: ConfigEntry +) -> dict[str, Any]: + """Return diagnostics for a config entry.""" + data = {} + coordinator = hass.data[DOMAIN][entry.entry_id] + devices = [] + # Don't cause a refresh when fetching devices + all_devices = await coordinator.client.get_devices("all", False) + for device in all_devices: + data[device.serial_number] = device.data + return data +