mirror of
https://github.com/home-assistant/core.git
synced 2026-05-31 12:44:04 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Support for Aurora Forecast sensor."""
|
|
|
|
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
|
from homeassistant.const import PERCENTAGE
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
|
|
from .coordinator import AuroraConfigEntry
|
|
from .entity import AuroraEntity
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: AuroraConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up the sensor platform."""
|
|
|
|
async_add_entities(
|
|
[
|
|
AuroraSensor(
|
|
coordinator=entry.runtime_data,
|
|
translation_key="visibility",
|
|
)
|
|
]
|
|
)
|
|
|
|
|
|
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) -> int:
|
|
"""Return % chance the aurora is visible."""
|
|
return self.coordinator.data
|