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 airly import Airly
8 
9 from homeassistant.components import system_health
10 from homeassistant.core import HomeAssistant, callback
11 
12 from . import AirlyConfigEntry
13 from .const import DOMAIN
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: AirlyConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
27 
28  requests_remaining = config_entry.runtime_data.airly.requests_remaining
29  requests_per_day = config_entry.runtime_data.airly.requests_per_day
30 
31  return {
32  "can_reach_server": system_health.async_check_can_reach_url(
33  hass, Airly.AIRLY_API_URL
34  ),
35  "requests_remaining": requests_remaining,
36  "requests_per_day": requests_per_day,
37  }
None async_register(HomeAssistant hass, system_health.SystemHealthRegistration register)
dict[str, Any] system_health_info(HomeAssistant hass)