mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Use entry.as_dict()
in Notion diagnostics (#80114)
This commit is contained in:
parent
c05390e09b
commit
020b7e9762
@ -5,18 +5,26 @@ from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
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.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
CONF_DEVICE_KEY = "device_key"
|
||||
CONF_HARDWARE_ID = "hardware_id"
|
||||
CONF_LAST_BRIDGE_HARDWARE_ID = "last_bridge_hardware_id"
|
||||
CONF_TITLE = "title"
|
||||
|
||||
TO_REDACT = {
|
||||
CONF_DEVICE_KEY,
|
||||
CONF_EMAIL,
|
||||
CONF_HARDWARE_ID,
|
||||
CONF_LAST_BRIDGE_HARDWARE_ID,
|
||||
CONF_PASSWORD,
|
||||
# Config entry title and unique ID may contain sensitive data:
|
||||
CONF_TITLE,
|
||||
CONF_UNIQUE_ID,
|
||||
CONF_USERNAME,
|
||||
}
|
||||
|
||||
@ -27,4 +35,7 @@ async def async_get_config_entry_diagnostics(
|
||||
"""Return diagnostics for a config entry."""
|
||||
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,12 +7,26 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
||||
"""Test config entry diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "notion",
|
||||
"title": REDACTED,
|
||||
"data": {"username": REDACTED, "password": REDACTED},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"data": {
|
||||
"bridges": {
|
||||
"12345": {
|
||||
"id": 12345,
|
||||
"name": None,
|
||||
"mode": "home",
|
||||
"hardware_id": "0x1234567890abcdef",
|
||||
"hardware_id": REDACTED,
|
||||
"hardware_revision": 4,
|
||||
"firmware_version": {
|
||||
"wifi": "0.121.0",
|
||||
@ -36,12 +50,12 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
||||
"id": 123456,
|
||||
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||
"user": {"id": 12345, "email": REDACTED},
|
||||
"bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"},
|
||||
"last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||
"bridge": {"id": 12345, "hardware_id": REDACTED},
|
||||
"last_bridge_hardware_id": REDACTED,
|
||||
"name": "Bathroom Sensor",
|
||||
"location_id": 123456,
|
||||
"system_id": 12345,
|
||||
"hardware_id": "0x1234567890abcdef",
|
||||
"hardware_id": REDACTED,
|
||||
"firmware_version": "1.1.2",
|
||||
"hardware_revision": 5,
|
||||
"device_key": REDACTED,
|
||||
@ -62,12 +76,12 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
||||
"id": 132462,
|
||||
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||
"user": {"id": 12345, "email": REDACTED},
|
||||
"bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"},
|
||||
"last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||
"bridge": {"id": 12345, "hardware_id": REDACTED},
|
||||
"last_bridge_hardware_id": REDACTED,
|
||||
"name": "Living Room Sensor",
|
||||
"location_id": 123456,
|
||||
"system_id": 12345,
|
||||
"hardware_id": "0x1234567890abcdef",
|
||||
"hardware_id": REDACTED,
|
||||
"firmware_version": "1.1.2",
|
||||
"hardware_revision": 5,
|
||||
"device_key": REDACTED,
|
||||
@ -108,4 +122,5 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion):
|
||||
"links": {"sensor": 525993},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user