Use `entry.as_dict()` in Notion diagnostics (#80114)
parent
c05390e09b
commit
020b7e9762
|
@ -5,18 +5,26 @@ from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import async_redact_data
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_UNIQUE_ID, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
CONF_DEVICE_KEY = "device_key"
|
CONF_DEVICE_KEY = "device_key"
|
||||||
|
CONF_HARDWARE_ID = "hardware_id"
|
||||||
|
CONF_LAST_BRIDGE_HARDWARE_ID = "last_bridge_hardware_id"
|
||||||
|
CONF_TITLE = "title"
|
||||||
|
|
||||||
TO_REDACT = {
|
TO_REDACT = {
|
||||||
CONF_DEVICE_KEY,
|
CONF_DEVICE_KEY,
|
||||||
CONF_EMAIL,
|
CONF_EMAIL,
|
||||||
|
CONF_HARDWARE_ID,
|
||||||
|
CONF_LAST_BRIDGE_HARDWARE_ID,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
|
# Config entry title and unique ID may contain sensitive data:
|
||||||
|
CONF_TITLE,
|
||||||
|
CONF_UNIQUE_ID,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,4 +35,7 @@ async def async_get_config_entry_diagnostics(
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
return async_redact_data(coordinator.data, TO_REDACT)
|
return {
|
||||||
|
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||||
|
"data": async_redact_data(coordinator.data, TO_REDACT),
|
||||||
|
}
|
||||||
|
|
|
@ -7,105 +7,120 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||||
"bridges": {
|
"entry": {
|
||||||
"12345": {
|
"entry_id": config_entry.entry_id,
|
||||||
"id": 12345,
|
"version": 1,
|
||||||
"name": None,
|
"domain": "notion",
|
||||||
"mode": "home",
|
"title": REDACTED,
|
||||||
"hardware_id": "0x1234567890abcdef",
|
"data": {"username": REDACTED, "password": REDACTED},
|
||||||
"hardware_revision": 4,
|
"options": {},
|
||||||
"firmware_version": {
|
"pref_disable_new_entities": False,
|
||||||
"wifi": "0.121.0",
|
"pref_disable_polling": False,
|
||||||
"wifi_app": "3.3.0",
|
"source": "user",
|
||||||
"silabs": "1.0.1",
|
"unique_id": REDACTED,
|
||||||
},
|
"disabled_by": None,
|
||||||
"missing_at": None,
|
|
||||||
"created_at": "2019-04-30T01:43:50.497Z",
|
|
||||||
"updated_at": "2019-04-30T01:44:43.749Z",
|
|
||||||
"system_id": 12345,
|
|
||||||
"firmware": {
|
|
||||||
"wifi": "0.121.0",
|
|
||||||
"wifi_app": "3.3.0",
|
|
||||||
"silabs": "1.0.1",
|
|
||||||
},
|
|
||||||
"links": {"system": 12345},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"sensors": {
|
"data": {
|
||||||
"123456": {
|
"bridges": {
|
||||||
"id": 123456,
|
"12345": {
|
||||||
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
"id": 12345,
|
||||||
"user": {"id": 12345, "email": REDACTED},
|
"name": None,
|
||||||
"bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"},
|
"mode": "home",
|
||||||
"last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
"hardware_id": REDACTED,
|
||||||
"name": "Bathroom Sensor",
|
"hardware_revision": 4,
|
||||||
"location_id": 123456,
|
"firmware_version": {
|
||||||
"system_id": 12345,
|
"wifi": "0.121.0",
|
||||||
"hardware_id": "0x1234567890abcdef",
|
"wifi_app": "3.3.0",
|
||||||
"firmware_version": "1.1.2",
|
"silabs": "1.0.1",
|
||||||
"hardware_revision": 5,
|
},
|
||||||
"device_key": REDACTED,
|
"missing_at": None,
|
||||||
"encryption_key": True,
|
"created_at": "2019-04-30T01:43:50.497Z",
|
||||||
"installed_at": "2019-04-30T01:57:34.443Z",
|
"updated_at": "2019-04-30T01:44:43.749Z",
|
||||||
"calibrated_at": "2019-04-30T01:57:35.651Z",
|
"system_id": 12345,
|
||||||
"last_reported_at": "2019-04-30T02:20:04.821Z",
|
"firmware": {
|
||||||
"missing_at": None,
|
"wifi": "0.121.0",
|
||||||
"updated_at": "2019-04-30T01:57:36.129Z",
|
"wifi_app": "3.3.0",
|
||||||
"created_at": "2019-04-30T01:56:45.932Z",
|
"silabs": "1.0.1",
|
||||||
"signal_strength": 5,
|
},
|
||||||
"links": {"location": 123456},
|
"links": {"system": 12345},
|
||||||
"lqi": 0,
|
}
|
||||||
"rssi": -46,
|
|
||||||
"surface_type": None,
|
|
||||||
},
|
},
|
||||||
"132462": {
|
"sensors": {
|
||||||
"id": 132462,
|
"123456": {
|
||||||
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
"id": 123456,
|
||||||
"user": {"id": 12345, "email": REDACTED},
|
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||||
"bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"},
|
"user": {"id": 12345, "email": REDACTED},
|
||||||
"last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
"bridge": {"id": 12345, "hardware_id": REDACTED},
|
||||||
"name": "Living Room Sensor",
|
"last_bridge_hardware_id": REDACTED,
|
||||||
"location_id": 123456,
|
"name": "Bathroom Sensor",
|
||||||
"system_id": 12345,
|
"location_id": 123456,
|
||||||
"hardware_id": "0x1234567890abcdef",
|
"system_id": 12345,
|
||||||
"firmware_version": "1.1.2",
|
"hardware_id": REDACTED,
|
||||||
"hardware_revision": 5,
|
"firmware_version": "1.1.2",
|
||||||
"device_key": REDACTED,
|
"hardware_revision": 5,
|
||||||
"encryption_key": True,
|
"device_key": REDACTED,
|
||||||
"installed_at": "2019-04-30T01:45:56.169Z",
|
"encryption_key": True,
|
||||||
"calibrated_at": "2019-04-30T01:46:06.256Z",
|
"installed_at": "2019-04-30T01:57:34.443Z",
|
||||||
"last_reported_at": "2019-04-30T02:20:04.829Z",
|
"calibrated_at": "2019-04-30T01:57:35.651Z",
|
||||||
"missing_at": None,
|
"last_reported_at": "2019-04-30T02:20:04.821Z",
|
||||||
"updated_at": "2019-04-30T01:46:07.717Z",
|
"missing_at": None,
|
||||||
"created_at": "2019-04-30T01:45:14.148Z",
|
"updated_at": "2019-04-30T01:57:36.129Z",
|
||||||
"signal_strength": 5,
|
"created_at": "2019-04-30T01:56:45.932Z",
|
||||||
"links": {"location": 123456},
|
"signal_strength": 5,
|
||||||
"lqi": 0,
|
"links": {"location": 123456},
|
||||||
"rssi": -30,
|
"lqi": 0,
|
||||||
"surface_type": None,
|
"rssi": -46,
|
||||||
|
"surface_type": None,
|
||||||
|
},
|
||||||
|
"132462": {
|
||||||
|
"id": 132462,
|
||||||
|
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||||
|
"user": {"id": 12345, "email": REDACTED},
|
||||||
|
"bridge": {"id": 12345, "hardware_id": REDACTED},
|
||||||
|
"last_bridge_hardware_id": REDACTED,
|
||||||
|
"name": "Living Room Sensor",
|
||||||
|
"location_id": 123456,
|
||||||
|
"system_id": 12345,
|
||||||
|
"hardware_id": REDACTED,
|
||||||
|
"firmware_version": "1.1.2",
|
||||||
|
"hardware_revision": 5,
|
||||||
|
"device_key": REDACTED,
|
||||||
|
"encryption_key": True,
|
||||||
|
"installed_at": "2019-04-30T01:45:56.169Z",
|
||||||
|
"calibrated_at": "2019-04-30T01:46:06.256Z",
|
||||||
|
"last_reported_at": "2019-04-30T02:20:04.829Z",
|
||||||
|
"missing_at": None,
|
||||||
|
"updated_at": "2019-04-30T01:46:07.717Z",
|
||||||
|
"created_at": "2019-04-30T01:45:14.148Z",
|
||||||
|
"signal_strength": 5,
|
||||||
|
"links": {"location": 123456},
|
||||||
|
"lqi": 0,
|
||||||
|
"rssi": -30,
|
||||||
|
"surface_type": None,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
"tasks": {
|
||||||
"tasks": {
|
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": {
|
||||||
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": {
|
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||||
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
"task_type": "low_battery",
|
||||||
"task_type": "low_battery",
|
"sensor_data": [],
|
||||||
"sensor_data": [],
|
"status": {
|
||||||
"status": {
|
"insights": {
|
||||||
"insights": {
|
"primary": {
|
||||||
"primary": {
|
"from_state": None,
|
||||||
"from_state": None,
|
"to_state": "high",
|
||||||
"to_state": "high",
|
"data_received_at": "2020-11-17T18:40:27.024Z",
|
||||||
"data_received_at": "2020-11-17T18:40:27.024Z",
|
"origin": {},
|
||||||
"origin": {},
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
"created_at": "2020-11-17T18:40:27.024Z",
|
||||||
"created_at": "2020-11-17T18:40:27.024Z",
|
"updated_at": "2020-11-17T18:40:27.033Z",
|
||||||
"updated_at": "2020-11-17T18:40:27.033Z",
|
"sensor_id": 525993,
|
||||||
"sensor_id": 525993,
|
"model_version": "4.1",
|
||||||
"model_version": "4.1",
|
"configuration": {},
|
||||||
"configuration": {},
|
"links": {"sensor": 525993},
|
||||||
"links": {"sensor": 525993},
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue