1 """Support for Netatmo binary sensors."""
4 BinarySensorDeviceClass,
6 BinarySensorEntityDescription,
13 from .const
import NETATMO_CREATE_WEATHER_SENSOR
14 from .data_handler
import NetatmoDevice
15 from .entity
import NetatmoWeatherModuleEntity
17 BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
20 device_class=BinarySensorDeviceClass.CONNECTIVITY,
26 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
28 """Set up Netatmo binary sensors based on a config entry."""
31 def _create_weather_binary_sensor_entity(netatmo_device: NetatmoDevice) ->
None:
34 for description
in BINARY_SENSOR_TYPES
35 if description.key
in netatmo_device.device.features
38 entry.async_on_unload(
40 hass, NETATMO_CREATE_WEATHER_SENSOR, _create_weather_binary_sensor_entity
46 """Implementation of a Netatmo binary sensor."""
49 self, device: NetatmoDevice, description: BinarySensorEntityDescription
51 """Initialize a Netatmo binary sensor."""
54 self.
_attr_unique_id_attr_unique_id = f
"{self.device.entity_id}-{description.key}"
58 """Update the entity's state."""
None __init__(self, NetatmoDevice device, BinarySensorEntityDescription description)
None async_update_callback(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)