1 """Sensor platform support for wiffi devices."""
14 from .const
import CREATE_ENTITY_SIGNAL
15 from .entity
import WiffiEntity
16 from .wiffi_strings
import (
21 WIFFI_UOM_TEMP_CELSIUS,
25 UOM_TO_DEVICE_CLASS_MAP = {
26 WIFFI_UOM_TEMP_CELSIUS: SensorDeviceClass.TEMPERATURE,
27 WIFFI_UOM_PERCENT: SensorDeviceClass.HUMIDITY,
28 WIFFI_UOM_MILLI_BAR: SensorDeviceClass.PRESSURE,
29 WIFFI_UOM_LUX: SensorDeviceClass.ILLUMINANCE,
34 WIFFI_UOM_DEGREE: DEGREE,
35 WIFFI_UOM_TEMP_CELSIUS: UnitOfTemperature.CELSIUS,
36 WIFFI_UOM_MILLI_BAR: UnitOfPressure.MBAR,
37 WIFFI_UOM_LUX: LIGHT_LUX,
43 config_entry: ConfigEntry,
44 async_add_entities: AddEntitiesCallback,
46 """Set up platform for a new integration.
48 Called by the HA framework after async_forward_entry_setups has been called
49 during initialization of a new integration (= wiffi).
53 def _create_entity(device, metric):
54 """Create platform specific entities."""
58 entities.append(
NumberEntity(device, metric, config_entry.options))
59 elif metric.is_string:
60 entities.append(
StringEntity(device, metric, config_entry.options))
68 """Entity for wiffi metrics which have a number value."""
71 """Initialize the entity."""
72 super().
__init__(device, metric, options)
74 metric.unit_of_measurement
77 metric.unit_of_measurement, metric.unit_of_measurement
90 """Return true if value is valid."""
95 """Update the value of the entity.
97 Called if a new message has been received from the wiffi device.
101 metric.unit_of_measurement, metric.unit_of_measurement
110 """Entity for wiffi metrics which have a string value."""
113 """Initialize the entity."""
114 super().
__init__(device, metric, options)
120 """Return true if value is valid."""
125 """Update the value of the entity.
127 Called if a new message has been received from the wiffi device.
def reset_expiration_date(self)
def _is_measurement_entity(self)
def _is_metered_entity(self)
def __init__(self, device, metric, options)
def _update_value_callback(self, device, metric)
_attr_native_unit_of_measurement
def _update_value_callback(self, device, metric)
def __init__(self, device, metric, options)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)