mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 10:47:51 +00:00

* Add diagnostic information to DSMR Switches to runtime_data to get access to the last telegram received. * Correct import of domain * Apply suggestions from code review Co-authored-by: G Johansson <goran.johansson@shiftit.se> --------- Co-authored-by: G Johansson <goran.johansson@shiftit.se>
29 lines
704 B
Python
29 lines
704 B
Python
"""Diagnostics support for DSMR."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.util.json import json_loads
|
|
|
|
from . import DsmrConfigEntry
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, config_entry: DsmrConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
|
|
return {
|
|
"entry": {
|
|
"data": {
|
|
**config_entry.data,
|
|
},
|
|
"unique_id": config_entry.unique_id,
|
|
},
|
|
"data": json_loads(config_entry.runtime_data.telegram.to_json())
|
|
if config_entry.runtime_data.telegram
|
|
else None,
|
|
}
|