1 """BinarySensor integration microBees."""
3 from microBeesPy
import Sensor
6 BinarySensorDeviceClass,
8 BinarySensorEntityDescription,
14 from .const
import DOMAIN
15 from .coordinator
import MicroBeesUpdateCoordinator
16 from .entity
import MicroBeesEntity
18 BINARYSENSOR_TYPES = {
20 device_class=BinarySensorDeviceClass.MOTION,
24 device_class=BinarySensorDeviceClass.DOOR,
28 device_class=BinarySensorDeviceClass.MOISTURE,
29 key=
"moisture_sensor",
32 device_class=BinarySensorDeviceClass.SMOKE,
39 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
41 """Set up the microBees binary sensor platform."""
42 coordinator: MicroBeesUpdateCoordinator = hass.data[DOMAIN][
46 MBBinarySensor(coordinator, entity_description, bee_id, binary_sensor.id)
47 for bee_id, bee
in coordinator.data.bees.items()
48 for binary_sensor
in bee.sensors
49 if (entity_description := BINARYSENSOR_TYPES.get(binary_sensor.device_type))
55 """Representation of a microBees BinarySensor."""
59 coordinator: MicroBeesUpdateCoordinator,
60 entity_description: BinarySensorEntityDescription,
64 """Initialize the microBees BinarySensor."""
65 super().
__init__(coordinator, bee_id)
72 """Name of the BinarySensor."""
73 return self.
sensorsensor.name
77 """Return the state of the BinarySensor."""
78 return self.
sensorsensor.value
82 """Return the BinarySensor."""
83 return self.coordinator.data.sensors[self.
sensor_idsensor_id]
None __init__(self, MicroBeesUpdateCoordinator coordinator, BinarySensorEntityDescription entity_description, int bee_id, int sensor_id)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)