Skip to content

Commit 89eb796

Browse files
feat: Added system health
1 parent 0f07258 commit 89eb796

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""System Health platform for panda_status custom component."""
2+
3+
from typing import TYPE_CHECKING, Any
4+
5+
from custom_components.panda_status.const import DOMAIN
6+
from homeassistant.components import system_health
7+
from homeassistant.const import CONF_URL
8+
from homeassistant.core import HomeAssistant, callback
9+
10+
if TYPE_CHECKING:
11+
from .data import PandaStatusConfigEntry
12+
13+
14+
@callback
15+
def async_register(
16+
hass: HomeAssistant, # noqa: ARG001
17+
register: system_health.SystemHealthRegistration,
18+
) -> None:
19+
"""Register system health callbacks."""
20+
register.async_register_info(system_health_info)
21+
22+
23+
async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
24+
"""Get info for the info page."""
25+
config_entry: PandaStatusConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
26+
27+
return {
28+
"can_reach_server": system_health.async_check_can_reach_url(
29+
hass, config_entry.data[CONF_URL]
30+
),
31+
}

custom_components/panda_status/translations/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
"abort": {
1717
"already_configured": "This entry is already configured."
1818
}
19+
},
20+
"system_health": {
21+
"info": {
22+
"can_reach_server": "WebSocket reachable"
23+
}
1924
}
2025
}

0 commit comments

Comments
 (0)