Use `entry.as_dict()` in RainMachine diagnostics (#80118)
* Use `entry.as_dict()` in RainMachine diagnostics * One callpull/80129/head^2
parent
8bc9aa9ea4
commit
687987f05b
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_PASSWORD,
|
||||
CONF_UNIQUE_ID,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -32,6 +33,8 @@ TO_REDACT = {
|
|||
CONF_STATION_NAME,
|
||||
CONF_STATION_SOURCE,
|
||||
CONF_TIMEZONE,
|
||||
# Config entry unique ID may contain sensitive data:
|
||||
CONF_UNIQUE_ID,
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,20 +50,16 @@ async def async_get_config_entry_diagnostics(
|
|||
LOGGER.warning("Unable to download controller-specific diagnostics")
|
||||
controller_diagnostics = None
|
||||
|
||||
return {
|
||||
"entry": {
|
||||
"title": entry.title,
|
||||
"data": async_redact_data(entry.data, TO_REDACT),
|
||||
"options": dict(entry.options),
|
||||
},
|
||||
"data": {
|
||||
"coordinator": async_redact_data(
|
||||
{
|
||||
return async_redact_data(
|
||||
{
|
||||
"entry": entry.as_dict(),
|
||||
"data": {
|
||||
"coordinator": {
|
||||
api_category: controller.data
|
||||
for api_category, controller in data.coordinators.items()
|
||||
},
|
||||
TO_REDACT,
|
||||
),
|
||||
"controller_diagnostics": controller_diagnostics,
|
||||
"controller_diagnostics": controller_diagnostics,
|
||||
},
|
||||
},
|
||||
}
|
||||
TO_REDACT,
|
||||
)
|
||||
|
|
|
@ -10,6 +10,9 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach
|
|||
"""Test config entry diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 2,
|
||||
"domain": "rainmachine",
|
||||
"title": "Mock Title",
|
||||
"data": {
|
||||
"ip_address": "192.168.1.100",
|
||||
|
@ -18,14 +21,15 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach
|
|||
"ssl": True,
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"data": {
|
||||
"coordinator": {
|
||||
"api.versions": {
|
||||
"apiVer": "4.6.1",
|
||||
"hwVer": "3",
|
||||
"swVer": "4.0.1144",
|
||||
},
|
||||
"api.versions": {"apiVer": "4.6.1", "hwVer": "3", "swVer": "4.0.1144"},
|
||||
"machine.firmware_update_status": {
|
||||
"lastUpdateCheckTimestamp": 1657825288,
|
||||
"packageDetails": [],
|
||||
|
@ -628,6 +632,9 @@ async def test_entry_diagnostics_failed_controller_diagnostics(
|
|||
controller.diagnostics.current.side_effect = RainMachineError
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 2,
|
||||
"domain": "rainmachine",
|
||||
"title": "Mock Title",
|
||||
"data": {
|
||||
"ip_address": "192.168.1.100",
|
||||
|
@ -636,14 +643,15 @@ async def test_entry_diagnostics_failed_controller_diagnostics(
|
|||
"ssl": True,
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"data": {
|
||||
"coordinator": {
|
||||
"api.versions": {
|
||||
"apiVer": "4.6.1",
|
||||
"hwVer": "3",
|
||||
"swVer": "4.0.1144",
|
||||
},
|
||||
"api.versions": {"apiVer": "4.6.1", "hwVer": "3", "swVer": "4.0.1144"},
|
||||
"machine.firmware_update_status": {
|
||||
"lastUpdateCheckTimestamp": 1657825288,
|
||||
"packageDetails": [],
|
||||
|
|
Loading…
Reference in New Issue