mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add diagnostics support to TwenteMilieu (#64627)
This commit is contained in:
parent
4c83ecd7bd
commit
4f4fca0d14
22
homeassistant/components/twentemilieu/diagnostics.py
Normal file
22
homeassistant/components/twentemilieu/diagnostics.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""Diagnostics support for TwenteMilieu."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.data[CONF_ID]]
|
||||
return {
|
||||
waste_type: waste_date.isoformat() if waste_date else None
|
||||
for waste_type, waste_date in coordinator.data.items()
|
||||
}
|
24
tests/components/twentemilieu/test_diagnostics.py
Normal file
24
tests/components/twentemilieu/test_diagnostics.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""Tests for the diagnostics data provided by the TwenteMilieu integration."""
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSession,
|
||||
init_integration: MockConfigEntry,
|
||||
):
|
||||
"""Test diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, init_integration
|
||||
) == {
|
||||
"0": "2021-11-01",
|
||||
"1": "2021-11-02",
|
||||
"2": None,
|
||||
"6": "2022-01-06",
|
||||
"10": "2021-11-03",
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user