Skip to content

Commit

Permalink
feat(diagnostics): includes discovered devices in downlaoded data (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou authored Jan 24, 2025
1 parent 2500014 commit a0a9fcf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/localtuya/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.helpers.device_registry import DeviceEntry

from . import HassLocalTuyaData
from .const import CONF_LOCAL_KEY, CONF_USER_ID, DOMAIN, CONF_NO_CLOUD
from .const import CONF_LOCAL_KEY, CONF_USER_ID, DOMAIN, CONF_NO_CLOUD, DATA_DISCOVERY

CLOUD_DEVICES = "cloud_devices"
DEVICE_CONFIG = "device_config"
Expand All @@ -31,7 +31,6 @@ async def async_get_config_entry_diagnostics(
data = dict(entry.data)
hass_localtuya: HassLocalTuyaData = hass.data[DOMAIN][entry.entry_id]
tuya_api = hass_localtuya.cloud_data
task_dps_query = None
if data.get(CONF_NO_CLOUD, True) is not True:
await hass.async_create_task(tuya_api.async_get_devices_dps_query())
# censoring private information on integration diagnostic data
Expand All @@ -47,7 +46,8 @@ async def async_get_config_entry_diagnostics(
for obf, obf_len in DATA_OBFUSCATE.items():
if ob := data[CLOUD_DEVICES][dev_id].get(obf):
data[CLOUD_DEVICES][dev_id][obf] = obfuscate(ob, obf_len, obf_len)

if discovery := hass.data[DOMAIN].get(DATA_DISCOVERY):
data["Discovered_Devices"] = discovery.devices
return data


Expand Down Expand Up @@ -76,6 +76,8 @@ async def async_get_device_diagnostics(
# data[DEVICE_CLOUD_INFO][CONF_LOCAL_KEY] = local_key_obfuscated

# data["log"] = hass.data[DOMAIN][CONF_DEVICES][dev_id].logger.retrieve_log()
if discovery := hass.data[DOMAIN].get(DATA_DISCOVERY):
data["Discovered_Devices"] = discovery.devices.get(dev_id)
return data


Expand Down

0 comments on commit a0a9fcf

Please sign in to comment.