Skip to content

Commit 6b1ad5e

Browse files
committed
Introduced diagnostics download feature
1 parent de615df commit 6b1ad5e

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

custom_components/daikin_residential/daikin_api.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -484,16 +484,19 @@ async def getCloudDeviceDetails(self):
484484

485485
async def getCloudDevices(self):
486486
"""Get array of DaikinResidentialDevice objects and get their data."""
487-
json_data = await self.getCloudDeviceDetails()
487+
self.json_data = await self.getCloudDeviceDetails()
488488
res = {}
489-
for dev_data in json_data or []:
489+
for dev_data in self.json_data or []:
490490
device = Appliance(dev_data, self)
491491
gateway_model = device.get_value("gateway", "modelInfo")
492492
device_model = device.desc["deviceModel"]
493493
if gateway_model is None:
494494
_LOGGER.warning("Device with ID '%s' is filtered out", dev_data["id"])
495495
elif device_model == "Altherma":
496-
_LOGGER.warning("Device with ID '%s' is filtered out because it is an Altherma", dev_data["id"])
496+
_LOGGER.warning(
497+
"Device with ID '%s' is filtered out because it is an Altherma",
498+
dev_data["id"],
499+
)
497500
else:
498501
res[dev_data["id"]] = device
499502
return res
@@ -508,8 +511,8 @@ async def async_update(self, **kwargs):
508511

509512
_LOGGER.debug("API UPDATE")
510513

511-
json_data = await self.getCloudDeviceDetails()
512-
for dev_data in json_data or []:
514+
self.json_data = await self.getCloudDeviceDetails()
515+
for dev_data in self.json_data or []:
513516
if dev_data["id"] in self.hass.data[DOMAIN][DAIKIN_DEVICES]:
514517
self.hass.data[DOMAIN][DAIKIN_DEVICES][dev_data["id"]].setJsonData(
515518
dev_data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Diagnostics support for Daikin Diagnostics."""
2+
from __future__ import annotations
3+
from typing import Any
4+
5+
from homeassistant.config_entries import ConfigEntry
6+
from homeassistant.core import HomeAssistant
7+
from homeassistant.helpers.device_registry import DeviceEntry
8+
9+
from .const import DOMAIN, DAIKIN_API, DAIKIN_DEVICES
10+
11+
12+
async def async_get_config_entry_diagnostics(
13+
hass: HomeAssistant, entry: ConfigEntry
14+
) -> dict[str, Any]:
15+
"""Return diagnostics for a config entry."""
16+
data = {}
17+
daikin_api = hass.data[DOMAIN][DAIKIN_API]
18+
data["tokenset"] = {**entry.data}
19+
data["json_data"] = daikin_api.json_data
20+
return data
21+
22+
23+
async def async_get_device_diagnostics(
24+
hass: HomeAssistant, entry: ConfigEntry, device: DeviceEntry
25+
) -> dict[str, Any]:
26+
"""Return diagnostics for a device entry."""
27+
data = {}
28+
dev_id = next(iter(device.identifiers))[1]
29+
daikin_device = hass.data[DOMAIN][DAIKIN_DEVICES][dev_id]
30+
data["device"] = device
31+
data["device_json_data"] = daikin_device.getDescription()
32+
return data

custom_components/daikin_residential/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "daikin_residential",
33
"name": "Daikin Residential Controller",
4-
"version": "2.0.0",
4+
"version": "2.2.0",
55
"documentation": "https://github.com/rospogrigio/daikin_residential/",
66
"dependencies": [],
77
"codeowners": [

0 commit comments

Comments
 (0)