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