* Add ecowitt integration * add tests * use total * use total * test coverage * Update homeassistant/components/ecowitt/__init__.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * Update homeassistant/components/ecowitt/binary_sensor.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * Update homeassistant/components/ecowitt/entity.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * Update homeassistant/components/ecowitt/diagnostics.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * add to async_on_unload * remove attr_name / unload callback * support unload platforms * using replace * address mapping * update type * mark final * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Fix bracket * Fix another bracket * Address comment * Add strings * update tests * Update homeassistant/components/ecowitt/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * update text * Update homeassistant/components/ecowitt/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Provides diagnostics for EcoWitt."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from aioecowitt import EcoWittListener
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.device_registry import DeviceEntry
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
async def async_get_device_diagnostics(
|
|
hass: HomeAssistant, entry: ConfigEntry, device: DeviceEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a device entry."""
|
|
ecowitt: EcoWittListener = hass.data[DOMAIN][entry.entry_id]
|
|
station_id = next(item[1] for item in device.identifiers if item[0] == DOMAIN)
|
|
|
|
station = ecowitt.stations[station_id]
|
|
|
|
data = {
|
|
"device": {
|
|
"name": station.station,
|
|
"model": station.model,
|
|
"frequency": station.frequency,
|
|
"version": station.version,
|
|
},
|
|
"raw": ecowitt.last_values[station_id],
|
|
"sensors": {
|
|
sensor.key: sensor.value
|
|
for sensor in station.sensors
|
|
if sensor.station.key == station_id
|
|
},
|
|
}
|
|
|
|
return data
|