Use `entry.as_dict()` in AirVisual diagnostics (#80109)
parent
f2207af1c9
commit
b41cd57c33
|
@ -5,13 +5,20 @@ from typing import Any
|
|||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_STATE
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_STATE,
|
||||
CONF_UNIQUE_ID,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import CONF_CITY, CONF_COUNTRY, DOMAIN
|
||||
|
||||
CONF_COORDINATES = "coordinates"
|
||||
CONF_TITLE = "title"
|
||||
|
||||
TO_REDACT = {
|
||||
CONF_API_KEY,
|
||||
|
@ -21,6 +28,9 @@ TO_REDACT = {
|
|||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_STATE,
|
||||
# Config entry title and unique ID may contain sensitive data:
|
||||
CONF_TITLE,
|
||||
CONF_UNIQUE_ID,
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,10 +41,6 @@ async def async_get_config_entry_diagnostics(
|
|||
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
return {
|
||||
"entry": {
|
||||
"title": entry.title,
|
||||
"data": async_redact_data(entry.data, TO_REDACT),
|
||||
"options": async_redact_data(entry.options, TO_REDACT),
|
||||
},
|
||||
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||
"data": async_redact_data(coordinator.data["data"], TO_REDACT),
|
||||
}
|
||||
|
|
|
@ -8,20 +8,28 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_airvisua
|
|||
"""Test config entry diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"title": "Mock Title",
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 2,
|
||||
"domain": "airvisual",
|
||||
"title": REDACTED,
|
||||
"data": {
|
||||
"api_key": REDACTED,
|
||||
"integration_type": "Geographical Location by Latitude/Longitude",
|
||||
"api_key": REDACTED,
|
||||
"latitude": REDACTED,
|
||||
"longitude": REDACTED,
|
||||
},
|
||||
"options": {
|
||||
"show_on_map": True,
|
||||
},
|
||||
"options": {"show_on_map": True},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"data": {
|
||||
"city": REDACTED,
|
||||
"state": REDACTED,
|
||||
"country": REDACTED,
|
||||
"location": {"type": "Point", "coordinates": REDACTED},
|
||||
"current": {
|
||||
"weather": {
|
||||
"ts": "2021-09-03T21:00:00.000Z",
|
||||
|
@ -40,10 +48,5 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_airvisua
|
|||
"maincn": "p2",
|
||||
},
|
||||
},
|
||||
"location": {
|
||||
"coordinates": REDACTED,
|
||||
"type": "Point",
|
||||
},
|
||||
"state": REDACTED,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue