Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions custom_components/parcelapp/system_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Provide info to system health."""

import os
from typing import Any

from homeassistant.components import system_health
from homeassistant.core import HomeAssistant, callback
from .const import DOMAIN, PARCEL_URL
from .coordinator import ParcelConfigEntry


@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."""
config_entry: ParcelConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
# quota_info = await config_entry.runtime_data.async_get_quota_info()

return {
# "consumed_requests": quota_info.consumed_requests,
# "remaining_requests": quota_info.requests_remaining,
"can_reach_server": system_health.async_check_can_reach_url(hass, PARCEL_URL),
}
5 changes: 5 additions & 0 deletions custom_components/parcelapp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,10 @@
}
}
}
},
"system_health": {
"info": {
"can_reach_server": "Reach Parcel server"
}
}
}