Home Assistant Unofficial Reference 2024.12.1
system_health.py
Go to the documentation of this file.
1 """Provide info to system health."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from accuweather.const import ENDPOINT
8 
9 from homeassistant.components import system_health
10 from homeassistant.core import HomeAssistant, callback
11 
12 from .const import DOMAIN
13 from .coordinator import AccuWeatherConfigEntry
14 
15 
16 @callback
18  hass: HomeAssistant, register: system_health.SystemHealthRegistration
19 ) -> None:
20  """Register system health callbacks."""
21  register.async_register_info(system_health_info)
22 
23 
24 async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
25  """Get info for the info page."""
26  config_entry: AccuWeatherConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
27 
28  remaining_requests = (
29  config_entry.runtime_data.coordinator_observation.accuweather.requests_remaining
30  )
31 
32  return {
33  "can_reach_server": system_health.async_check_can_reach_url(hass, ENDPOINT),
34  "remaining_requests": remaining_requests,
35  }
None async_register(HomeAssistant hass, system_health.SystemHealthRegistration register)
dict[str, Any] system_health_info(HomeAssistant hass)