Skip to content

Commit

Permalink
Introduced diagnostics download feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rospogrigio committed Feb 16, 2022
1 parent de615df commit 6b1ad5e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
13 changes: 8 additions & 5 deletions custom_components/daikin_residential/daikin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,19 @@ async def getCloudDeviceDetails(self):

async def getCloudDevices(self):
"""Get array of DaikinResidentialDevice objects and get their data."""
json_data = await self.getCloudDeviceDetails()
self.json_data = await self.getCloudDeviceDetails()
res = {}
for dev_data in json_data or []:
for dev_data in self.json_data or []:
device = Appliance(dev_data, self)
gateway_model = device.get_value("gateway", "modelInfo")
device_model = device.desc["deviceModel"]
if gateway_model is None:
_LOGGER.warning("Device with ID '%s' is filtered out", dev_data["id"])
elif device_model == "Altherma":
_LOGGER.warning("Device with ID '%s' is filtered out because it is an Altherma", dev_data["id"])
_LOGGER.warning(
"Device with ID '%s' is filtered out because it is an Altherma",
dev_data["id"],
)
else:
res[dev_data["id"]] = device
return res
Expand All @@ -508,8 +511,8 @@ async def async_update(self, **kwargs):

_LOGGER.debug("API UPDATE")

json_data = await self.getCloudDeviceDetails()
for dev_data in json_data or []:
self.json_data = await self.getCloudDeviceDetails()
for dev_data in self.json_data or []:
if dev_data["id"] in self.hass.data[DOMAIN][DAIKIN_DEVICES]:
self.hass.data[DOMAIN][DAIKIN_DEVICES][dev_data["id"]].setJsonData(
dev_data
Expand Down
32 changes: 32 additions & 0 deletions custom_components/daikin_residential/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""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 .const import DOMAIN, DAIKIN_API, DAIKIN_DEVICES


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
data = {}
daikin_api = hass.data[DOMAIN][DAIKIN_API]
data["tokenset"] = {**entry.data}
data["json_data"] = daikin_api.json_data
return data


async def async_get_device_diagnostics(
hass: HomeAssistant, entry: ConfigEntry, device: DeviceEntry
) -> dict[str, Any]:
"""Return diagnostics for a device entry."""
data = {}
dev_id = next(iter(device.identifiers))[1]
daikin_device = hass.data[DOMAIN][DAIKIN_DEVICES][dev_id]
data["device"] = device
data["device_json_data"] = daikin_device.getDescription()
return data
2 changes: 1 addition & 1 deletion custom_components/daikin_residential/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "daikin_residential",
"name": "Daikin Residential Controller",
"version": "2.0.0",
"version": "2.2.0",
"documentation": "https://github.com/rospogrigio/daikin_residential/",
"dependencies": [],
"codeowners": [
Expand Down

0 comments on commit 6b1ad5e

Please sign in to comment.