1 """Support for Plaato Airlock sensors."""
3 from __future__
import annotations
5 from pyplaato.models.device
import PlaatoDevice
6 from pyplaato.plaato
import PlaatoKeg
12 async_dispatcher_connect,
13 async_dispatcher_send,
18 from .
import ATTR_TEMP, SENSOR_UPDATE
28 from .entity
import PlaatoEntity
34 async_add_entities: AddEntitiesCallback,
35 discovery_info: DiscoveryInfoType |
None =
None,
37 """Set up the Plaato sensor."""
41 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
43 """Set up Plaato from a config entry."""
44 entry_data = hass.data[DOMAIN][entry.entry_id]
47 def _async_update_from_webhook(device_id, sensor_data: PlaatoDevice):
48 """Update/Create the sensors."""
49 entry_data[SENSOR_DATA] = sensor_data
51 if device_id != entry_data[DEVICE][DEVICE_ID]:
52 entry_data[DEVICE][DEVICE_ID] = device_id
56 for sensor_type
in sensor_data.sensors
60 for sensor_type
in sensor_data.sensors:
63 if entry.data[CONF_USE_WEBHOOK]:
66 coordinator = entry_data[COORDINATOR]
69 for sensor_type
in coordinator.data.sensors
74 """Representation of a Plaato Sensor."""
76 def __init__(self, data, sensor_type, coordinator=None) -> None:
77 """Initialize plaato sensor."""
78 super().
__init__(data, sensor_type, coordinator)
79 if sensor_type
is PlaatoKeg.Pins.TEMPERATURE
or sensor_type == ATTR_TEMP:
84 """Return the state of the sensor."""
89 """Return the unit of measurement."""
PlaatoDevice _sensor_data(self)
None __init__(self, data, sensor_type, coordinator=None)
def native_unit_of_measurement(self)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)
None async_dispatcher_send(HomeAssistant hass, str signal, *Any args)
str|None get_unit_of_measurement(HomeAssistant hass, str entity_id)