Skip to content

Commit 1ca6c4b

Browse files
joostlekballoob
authored andcommitted
Include device data in Withings diagnostics (home-assistant#150816)
1 parent 81377be commit 1ca6c4b

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

homeassistant/components/withings/diagnostics.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22

33
from __future__ import annotations
44

5+
from dataclasses import asdict
56
from typing import Any
67

78
from yarl import URL
89

10+
from homeassistant.components.diagnostics import async_redact_data
911
from homeassistant.components.webhook import async_generate_url as webhook_generate_url
1012
from homeassistant.const import CONF_WEBHOOK_ID
1113
from homeassistant.core import HomeAssistant
1214

1315
from . import CONF_CLOUDHOOK_URL, WithingsConfigEntry
1416

17+
TO_REDACT = {
18+
"device_id",
19+
"hashed_device_id",
20+
}
21+
1522

1623
async def async_get_config_entry_diagnostics(
1724
hass: HomeAssistant, entry: WithingsConfigEntry
@@ -53,4 +60,8 @@ async def async_get_config_entry_diagnostics(
5360
"received_sleep_data": withings_data.sleep_coordinator.data is not None,
5461
"received_workout_data": withings_data.workout_coordinator.data is not None,
5562
"received_activity_data": withings_data.activity_coordinator.data is not None,
63+
"devices": async_redact_data(
64+
[asdict(v) for v in withings_data.device_coordinator.data.values()],
65+
TO_REDACT,
66+
),
5667
}

tests/components/withings/snapshots/test_diagnostics.ambr

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# serializer version: 1
22
# name: test_diagnostics_cloudhook_instance
33
dict({
4+
'devices': list([
5+
dict({
6+
'battery': 'high',
7+
'device_id': '**REDACTED**',
8+
'device_type': 'Scale',
9+
'first_session_date': None,
10+
'hashed_device_id': '**REDACTED**',
11+
'last_session_date': '2023-09-04T22:39:39+00:00',
12+
'model': 5,
13+
'raw_model': 'Body+',
14+
}),
15+
]),
416
'has_cloudhooks': True,
517
'has_valid_external_webhook_url': True,
618
'received_activity_data': False,
@@ -64,6 +76,18 @@
6476
# ---
6577
# name: test_diagnostics_polling_instance
6678
dict({
79+
'devices': list([
80+
dict({
81+
'battery': 'high',
82+
'device_id': '**REDACTED**',
83+
'device_type': 'Scale',
84+
'first_session_date': None,
85+
'hashed_device_id': '**REDACTED**',
86+
'last_session_date': '2023-09-04T22:39:39+00:00',
87+
'model': 5,
88+
'raw_model': 'Body+',
89+
}),
90+
]),
6791
'has_cloudhooks': False,
6892
'has_valid_external_webhook_url': False,
6993
'received_activity_data': False,
@@ -127,6 +151,18 @@
127151
# ---
128152
# name: test_diagnostics_webhook_instance
129153
dict({
154+
'devices': list([
155+
dict({
156+
'battery': 'high',
157+
'device_id': '**REDACTED**',
158+
'device_type': 'Scale',
159+
'first_session_date': None,
160+
'hashed_device_id': '**REDACTED**',
161+
'last_session_date': '2023-09-04T22:39:39+00:00',
162+
'model': 5,
163+
'raw_model': 'Body+',
164+
}),
165+
]),
130166
'has_cloudhooks': False,
131167
'has_valid_external_webhook_url': True,
132168
'received_activity_data': False,

0 commit comments

Comments
 (0)