mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-11 09:39:00 +01:00
0afbef7f11
* added LAP-C601S-WUS (Core 600s Air Purifier) * fix style * better fix to diagnostic. * fix preset mode * add a log line. * add another debug log * add some missing fan devices. * auto discover preset_modes * auto discover fan speed range * fix fan speed and preset modes * fix fan speed number * add some debug log. * merge fix from main * rename a key in diagnostics.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Provides diagnostics for VeSync."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
def _if_has_attr_else_none(obj, attr):
|
|
return getattr(obj, attr) if hasattr(obj, attr) else None
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: ConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
data = hass.data[DOMAIN][entry.entry_id]
|
|
devices = {"fans": [], "outlets": [], "switches": [], "bulbs": []}
|
|
for type in ["fans", "outlets", "switches", "bulbs"]:
|
|
for d in data["manager"]._dev_list[type]:
|
|
devices[type].append(
|
|
{
|
|
"config_dict": _if_has_attr_else_none(d, "config_dict") or {},
|
|
"config": _if_has_attr_else_none(d, "config") or {},
|
|
"details": _if_has_attr_else_none(d, "details") or {},
|
|
}
|
|
)
|
|
return devices
|