Use entry.as_dict()
in OpenUV diagnostics (#80115)
This commit is contained in:
parent
020b7e9762
commit
4ea46bf841
2 changed files with 27 additions and 15 deletions
|
@ -5,18 +5,27 @@ 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_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
|
from homeassistant.const import (
|
||||||
|
CONF_API_KEY,
|
||||||
|
CONF_LATITUDE,
|
||||||
|
CONF_LONGITUDE,
|
||||||
|
CONF_UNIQUE_ID,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import OpenUV
|
from . import OpenUV
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
CONF_COORDINATES = "coordinates"
|
CONF_COORDINATES = "coordinates"
|
||||||
|
CONF_TITLE = "title"
|
||||||
|
|
||||||
TO_REDACT = {
|
TO_REDACT = {
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_LATITUDE,
|
CONF_LATITUDE,
|
||||||
CONF_LONGITUDE,
|
CONF_LONGITUDE,
|
||||||
|
# Config entry title and unique ID may contain sensitive data:
|
||||||
|
CONF_TITLE,
|
||||||
|
CONF_UNIQUE_ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,9 +36,6 @@ async def async_get_config_entry_diagnostics(
|
||||||
openuv: OpenUV = hass.data[DOMAIN][entry.entry_id]
|
openuv: OpenUV = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"entry": {
|
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||||
"data": async_redact_data(entry.data, TO_REDACT),
|
|
||||||
"options": async_redact_data(entry.options, TO_REDACT),
|
|
||||||
},
|
|
||||||
"data": async_redact_data(openuv.data, TO_REDACT),
|
"data": async_redact_data(openuv.data, TO_REDACT),
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,30 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_openuv):
|
||||||
)
|
)
|
||||||
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": {
|
||||||
|
"entry_id": config_entry.entry_id,
|
||||||
|
"version": 2,
|
||||||
|
"domain": "openuv",
|
||||||
|
"title": REDACTED,
|
||||||
"data": {
|
"data": {
|
||||||
"api_key": REDACTED,
|
"api_key": REDACTED,
|
||||||
"elevation": 0,
|
"elevation": 0,
|
||||||
"latitude": REDACTED,
|
"latitude": REDACTED,
|
||||||
"longitude": REDACTED,
|
"longitude": REDACTED,
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {"from_window": 3.5, "to_window": 3.5},
|
||||||
"from_window": 3.5,
|
"pref_disable_new_entities": False,
|
||||||
"to_window": 3.5,
|
"pref_disable_polling": False,
|
||||||
},
|
"source": "user",
|
||||||
|
"unique_id": REDACTED,
|
||||||
|
"disabled_by": None,
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
|
"protection_window": {
|
||||||
|
"from_time": "2018-07-30T15:17:49.750Z",
|
||||||
|
"from_uv": 3.2509,
|
||||||
|
"to_time": "2018-07-30T22:47:49.750Z",
|
||||||
|
"to_uv": 3.6483,
|
||||||
|
},
|
||||||
"uv": {
|
"uv": {
|
||||||
"uv": 8.2342,
|
"uv": 8.2342,
|
||||||
"uv_time": "2018-07-30T20:53:06.302Z",
|
"uv_time": "2018-07-30T20:53:06.302Z",
|
||||||
|
@ -62,11 +74,5 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_openuv):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"protection_window": {
|
|
||||||
"from_time": "2018-07-30T15:17:49.750Z",
|
|
||||||
"from_uv": 3.2509,
|
|
||||||
"to_time": "2018-07-30T22:47:49.750Z",
|
|
||||||
"to_uv": 3.6483,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue