1 """Platform for the opengarage.io sensor component."""
3 from __future__
import annotations
6 from typing
import cast
11 SensorEntityDescription,
17 SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
25 from .const
import DOMAIN
26 from .coordinator
import OpenGarageDataUpdateCoordinator
27 from .entity
import OpenGarageEntity
29 _LOGGER = logging.getLogger(__name__)
31 SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
34 native_unit_of_measurement=UnitOfLength.CENTIMETERS,
35 device_class=SensorDeviceClass.DISTANCE,
36 state_class=SensorStateClass.MEASUREMENT,
40 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
41 entity_category=EntityCategory.DIAGNOSTIC,
42 entity_registry_enabled_default=
False,
43 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
44 state_class=SensorStateClass.MEASUREMENT,
48 device_class=SensorDeviceClass.TEMPERATURE,
49 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
50 state_class=SensorStateClass.MEASUREMENT,
54 device_class=SensorDeviceClass.HUMIDITY,
55 native_unit_of_measurement=PERCENTAGE,
56 state_class=SensorStateClass.MEASUREMENT,
62 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
64 """Set up the OpenGarage sensors."""
65 open_garage_data_coordinator: OpenGarageDataUpdateCoordinator = hass.data[DOMAIN][
70 open_garage_data_coordinator,
71 cast(str, entry.unique_id),
74 for description
in SENSOR_TYPES
75 if description.key
in open_garage_data_coordinator.data
80 """Representation of a OpenGarage sensor."""
84 """Handle updated data from the coordinator."""
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)