Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support system health #6

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
36 changes: 36 additions & 0 deletions custom_components/xiaomi_home/system_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""Provide info to system health.
Users can find the aggregated system health by going to Settings > Repairs and
selecting System information in the three dots menu.
"""
from typing import Any
from homeassistant.components.system_health import SystemHealthRegistration
from homeassistant.core import HomeAssistant, callback

from .miot.const import DOMAIN


@callback
def async_register(
hass: HomeAssistant, register: 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: ExampleConfigEntry = 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,
# # checking the url can take a while, so set the coroutine in the info dict
# "can_reach_server": system_health.async_check_can_reach_url(hass, ENDPOINT),
# }
return {
'domain': DOMAIN,
'hello': 'world',
}
Loading