Add `diagnostics` platform for GIOS integration (#69918)
* Add diagnostics platform * Fix fixture datapull/70009/head
parent
6853db71e3
commit
7edbe66b26
|
@ -0,0 +1,24 @@
|
|||
"""Diagnostics support for GIOS."""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import GiosDataUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: GiosDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
diagnostics_data = {
|
||||
"config_entry": config_entry.as_dict(),
|
||||
"coordinator_data": asdict(coordinator.data),
|
||||
}
|
||||
|
||||
return diagnostics_data
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"aqi": {
|
||||
"name": "AQI",
|
||||
"id": null,
|
||||
"index": null,
|
||||
"value": "dobry"
|
||||
},
|
||||
"c6h6": {
|
||||
"name": "benzen",
|
||||
"id": 658,
|
||||
"index": "bardzo dobry",
|
||||
"value": 0.23789
|
||||
},
|
||||
"co": {
|
||||
"name": "tlenek węgla",
|
||||
"id": 660,
|
||||
"index": "dobry",
|
||||
"value": 251.874
|
||||
},
|
||||
"no2": {
|
||||
"name": "dwutlenek azotu",
|
||||
"id": 665,
|
||||
"index": "dobry",
|
||||
"value": 7.13411
|
||||
},
|
||||
"o3": {
|
||||
"name": "ozon",
|
||||
"id": 667,
|
||||
"index": "dobry",
|
||||
"value": 95.7768
|
||||
},
|
||||
"pm10": {
|
||||
"name": "py\u0142 zawieszony PM10",
|
||||
"id": 14395,
|
||||
"index": "dobry",
|
||||
"value": 16.8344
|
||||
},
|
||||
"pm25": {
|
||||
"name": "py\u0142 zawieszony PM2.5",
|
||||
"id": 670,
|
||||
"index": "dobry",
|
||||
"value": 4
|
||||
},
|
||||
"so2": {
|
||||
"name": "dwutlenek siarki",
|
||||
"id": 672,
|
||||
"index": "bardzo dobry",
|
||||
"value": 4.35478
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
"""Test GIOS diagnostics."""
|
||||
import json
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.components.gios import init_integration
|
||||
|
||||
|
||||
async def test_entry_diagnostics(hass, hass_client):
|
||||
"""Test config entry diagnostics."""
|
||||
entry = await init_integration(hass)
|
||||
|
||||
coordinator_data = json.loads(load_fixture("diagnostics_data.json", "gios"))
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert result["config_entry"] == {
|
||||
"entry_id": entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "gios",
|
||||
"title": "Home",
|
||||
"data": {
|
||||
"station_id": 123,
|
||||
"name": "Home",
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": "123",
|
||||
"disabled_by": None,
|
||||
}
|
||||
assert result["coordinator_data"] == coordinator_data
|
Loading…
Reference in New Issue