-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystem_health.py
30 lines (22 loc) · 966 Bytes
/
system_health.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Provide info to system health."""
from __future__ import annotations
from typing import Any
from homeassistant.components import system_health
from homeassistant.core import HomeAssistant, callback
from .const import DOMAIN, SOLCAST_URL
from .coordinator import SolcastUpdateCoordinator
@callback
def async_register(
hass: HomeAssistant, register: system_health.SystemHealthRegistration
) -> None:
"""Register system health callbacks."""
register.async_register_info(system_health_info)
async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
"""Get info for the info page."""
coordinator: SolcastUpdateCoordinator =list(hass.data[DOMAIN].values())[0]
used_requests = coordinator.solcast.get_api_used_count()
return {
"can_reach_server": system_health.async_check_can_reach_url(hass, SOLCAST_URL),
"used_requests": used_requests,
"rooftop_site_count": len(coordinator.solcast._sites),
}