mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Use entry.as_dict()
in Guardian diagnostics (#80112)
This commit is contained in:
parent
5743e9f83d
commit
0f002e7044
@ -5,6 +5,7 @@ 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_UNIQUE_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import GuardianData
|
from . import GuardianData
|
||||||
@ -13,11 +14,15 @@ from .const import CONF_UID, DOMAIN
|
|||||||
CONF_BSSID = "bssid"
|
CONF_BSSID = "bssid"
|
||||||
CONF_PAIRED_UIDS = "paired_uids"
|
CONF_PAIRED_UIDS = "paired_uids"
|
||||||
CONF_SSID = "ssid"
|
CONF_SSID = "ssid"
|
||||||
|
CONF_TITLE = "title"
|
||||||
|
|
||||||
TO_REDACT = {
|
TO_REDACT = {
|
||||||
CONF_BSSID,
|
CONF_BSSID,
|
||||||
CONF_PAIRED_UIDS,
|
CONF_PAIRED_UIDS,
|
||||||
CONF_SSID,
|
CONF_SSID,
|
||||||
|
# Config entry title and unique ID may contain sensitive data:
|
||||||
|
CONF_TITLE,
|
||||||
|
CONF_UNIQUE_ID,
|
||||||
CONF_UID,
|
CONF_UID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +34,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
data: GuardianData = hass.data[DOMAIN][entry.entry_id]
|
data: GuardianData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"entry": {
|
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||||
"title": entry.title,
|
|
||||||
"data": async_redact_data(entry.data, TO_REDACT),
|
|
||||||
},
|
|
||||||
"data": {
|
"data": {
|
||||||
"valve_controller": {
|
"valve_controller": {
|
||||||
api_category: async_redact_data(coordinator.data, TO_REDACT)
|
api_category: async_redact_data(coordinator.data, TO_REDACT)
|
||||||
|
@ -14,12 +14,21 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_guardian
|
|||||||
|
|
||||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||||
"entry": {
|
"entry": {
|
||||||
"title": "Mock Title",
|
"entry_id": config_entry.entry_id,
|
||||||
|
"version": 1,
|
||||||
|
"domain": "guardian",
|
||||||
|
"title": REDACTED,
|
||||||
"data": {
|
"data": {
|
||||||
|
"uid": REDACTED,
|
||||||
"ip_address": "192.168.1.100",
|
"ip_address": "192.168.1.100",
|
||||||
"port": 7777,
|
"port": 7777,
|
||||||
"uid": REDACTED,
|
|
||||||
},
|
},
|
||||||
|
"options": {},
|
||||||
|
"pref_disable_new_entities": False,
|
||||||
|
"pref_disable_polling": False,
|
||||||
|
"source": "user",
|
||||||
|
"unique_id": REDACTED,
|
||||||
|
"disabled_by": None,
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"valve_controller": {
|
"valve_controller": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user