Home Assistant Unofficial Reference 2024.12.1
sensor.py
Go to the documentation of this file.
1 """Support for Aurora Forecast sensor."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.components.sensor import SensorEntity, SensorStateClass
6 from homeassistant.const import PERCENTAGE
7 from homeassistant.core import HomeAssistant
8 from homeassistant.helpers.entity_platform import AddEntitiesCallback
9 
10 from . import AuroraConfigEntry
11 from .entity import AuroraEntity
12 
13 
15  hass: HomeAssistant,
16  entry: AuroraConfigEntry,
17  async_add_entities: AddEntitiesCallback,
18 ) -> None:
19  """Set up the sensor platform."""
20 
22  [
24  coordinator=entry.runtime_data,
25  translation_key="visibility",
26  )
27  ]
28  )
29 
30 
32  """Implementation of an aurora sensor."""
33 
34  _attr_native_unit_of_measurement = PERCENTAGE
35  _attr_state_class = SensorStateClass.MEASUREMENT
36 
37  @property
38  def native_value(self) -> int:
39  """Return % chance the aurora is visible."""
40  return self.coordinator.data
None async_setup_entry(HomeAssistant hass, AuroraConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: sensor.py:18