mirror of
https://github.com/home-assistant/core.git
synced 2026-05-18 14:29:57 +01:00
ce9875806d
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
38 lines
997 B
Python
38 lines
997 B
Python
"""Diagnostics support for Launch Library."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from pylaunches.types import Event, Launch
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .coordinator import LaunchLibraryConfigEntry
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant,
|
|
entry: LaunchLibraryConfigEntry,
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
|
|
coordinator = entry.runtime_data
|
|
if coordinator.data is None:
|
|
return {}
|
|
|
|
def _first_element(data: list[Launch | Event]) -> dict[str, Any] | None:
|
|
if not data:
|
|
return None
|
|
return data[0]
|
|
|
|
return {
|
|
"next_launch": _first_element(coordinator.data["upcoming_launches"]),
|
|
"starship_launch": _first_element(
|
|
coordinator.data["starship_events"].upcoming.launches
|
|
),
|
|
"starship_event": _first_element(
|
|
coordinator.data["starship_events"].upcoming.events
|
|
),
|
|
}
|