mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Improve aurora typing (#108217)
This commit is contained in:
parent
bdda38f274
commit
1b2a4d2bf3
@ -1,4 +1,6 @@
|
||||
"""Support for Aurora Forecast binary sensor."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -27,6 +29,6 @@ class AuroraSensor(AuroraEntity, BinarySensorEntity):
|
||||
"""Implementation of an aurora sensor."""
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if aurora is visible."""
|
||||
return self.coordinator.data > self.coordinator.threshold
|
||||
|
@ -51,7 +51,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
if user_input is not None:
|
||||
longitude = user_input[CONF_LONGITUDE]
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""The aurora component."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
@ -12,7 +13,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AuroraDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
class AuroraDataUpdateCoordinator(DataUpdateCoordinator[int]):
|
||||
"""Class to manage fetching data from the NOAA Aurora API."""
|
||||
|
||||
def __init__(
|
||||
@ -37,7 +38,7 @@ class AuroraDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
self.longitude = int(longitude)
|
||||
self.threshold = int(threshold)
|
||||
|
||||
async def _async_update_data(self):
|
||||
async def _async_update_data(self) -> int:
|
||||
"""Fetch the data from the NOAA Aurora Forecast."""
|
||||
|
||||
try:
|
||||
|
@ -1,4 +1,6 @@
|
||||
"""Support for Aurora Forecast sensor."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE
|
||||
@ -31,6 +33,6 @@ class AuroraSensor(AuroraEntity, SensorEntity):
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
def native_value(self) -> int:
|
||||
"""Return % chance the aurora is visible."""
|
||||
return self.coordinator.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user