* Bump aurora_api version to fix issues with NOAA conversion values. Fix #82587 * update requirements for aurora. * Add state_class to aurora sensor. * Fixed environment to run requirements_all script. * Revert "Add state_class to aurora sensor." This reverts commit213e21e842
. * Add state class to aurora sensor. * Revert "Fixed environment to run requirements_all script." This reverts commitf3f624226e
. * Revert "update requirements for aurora." This reverts commita3546ad88d
. * Revert "Bump aurora_api version to fix issues with NOAA conversion values. Fix #82587" This reverts commitfaf3ba7b5b
. * Move state class to _attr_state_class.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Support for Aurora Forecast sensor."""
|
|
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import PERCENTAGE
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from . import AuroraEntity
|
|
from .const import COORDINATOR, DOMAIN
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entries: AddEntitiesCallback
|
|
) -> None:
|
|
"""Set up the sensor platform."""
|
|
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
|
|
|
|
entity = AuroraSensor(
|
|
coordinator=coordinator,
|
|
name=f"{coordinator.name} Aurora Visibility %",
|
|
icon="mdi:gauge",
|
|
)
|
|
|
|
async_add_entries([entity])
|
|
|
|
|
|
class AuroraSensor(AuroraEntity, SensorEntity):
|
|
"""Implementation of an aurora sensor."""
|
|
|
|
_attr_native_unit_of_measurement = PERCENTAGE
|
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
|
|
|
@property
|
|
def native_value(self):
|
|
"""Return % chance the aurora is visible."""
|
|
return self.coordinator.data
|