Add system health streaming updates (#42831)
This commit is contained in:
parent
8a7febcfbe
commit
9f4480a634
6 changed files with 334 additions and 63 deletions
48
homeassistant/components/cloud/system_health.py
Normal file
48
homeassistant/components/cloud/system_health.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""Provide info to system health."""
|
||||
from hass_nabucasa import Cloud
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.components import system_health
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
from .client import CloudClient
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
@callback
|
||||
def async_register(
|
||||
hass: HomeAssistant, register: system_health.SystemHealthRegistration
|
||||
) -> None:
|
||||
"""Register system health callbacks."""
|
||||
register.async_register_info(system_health_info, "/config/cloud")
|
||||
|
||||
|
||||
async def system_health_info(hass):
|
||||
"""Get info for the info page."""
|
||||
cloud: Cloud = hass.data[DOMAIN]
|
||||
client: CloudClient = cloud.client
|
||||
|
||||
data = {
|
||||
"logged_in": cloud.is_logged_in,
|
||||
}
|
||||
|
||||
if cloud.is_logged_in:
|
||||
data["subscription_expiration"] = cloud.expiration_date
|
||||
data["relayer_connected"] = cloud.is_connected
|
||||
data["remote_enabled"] = client.prefs.remote_enabled
|
||||
data["remote_connected"] = cloud.remote.is_connected
|
||||
data["alexa_enabled"] = client.prefs.alexa_enabled
|
||||
data["google_enabled"] = client.prefs.google_enabled
|
||||
|
||||
data["can_reach_cert_server"] = system_health.async_check_can_reach_url(
|
||||
hass, cloud.acme_directory_server
|
||||
)
|
||||
data["can_reach_cloud_auth"] = system_health.async_check_can_reach_url(
|
||||
hass,
|
||||
f"https://cognito-idp.{cloud.region}.amazonaws.com/{cloud.user_pool_id}/.well-known/jwks.json",
|
||||
)
|
||||
data["can_reach_cloud"] = system_health.async_check_can_reach_url(
|
||||
hass, URL(cloud.relayer).with_scheme("https").with_path("/status")
|
||||
)
|
||||
|
||||
return data
|
Loading…
Add table
Add a link
Reference in a new issue