Maciej Bieniek bce5f8ee05
Improve AccuWeather type annotations (#50616)
* Improve type annotations

* Remove unused argument

* Simplify state logic

* Fix uvindex state

* Fix type for logger

* Increase tests coverage

* Fix pylint arguments-differ error

* Suggested change

* Suggested change

* Remove unnecessary variable

* Remove unnecessary conditions

* Use int instead of list for forecast days

* Add enabled to sensor types dicts

* Fix request_remaining conversion and tests

* Run hassfest

* Suggested change

* Suggested change

* Do not use StateType
2021-05-19 09:37:16 +01:00

32 lines
880 B
Python

"""Provide info to system health."""
from __future__ import annotations
from typing import Any
from accuweather.const import ENDPOINT
from homeassistant.components import system_health
from homeassistant.core import HomeAssistant, callback
from .const import COORDINATOR, DOMAIN
@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."""
remaining_requests = list(hass.data[DOMAIN].values())[0][
COORDINATOR
].accuweather.requests_remaining
return {
"can_reach_server": system_health.async_check_can_reach_url(hass, ENDPOINT),
"remaining_requests": remaining_requests,
}