1 """Support for MySensors binary sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
10 BinarySensorDeviceClass,
12 BinarySensorEntityDescription,
20 from .
import setup_mysensors_platform
21 from .const
import MYSENSORS_DISCOVERY, DiscoveryInfo
22 from .entity
import MySensorsChildEntity
23 from .helpers
import on_unload
26 @dataclass(frozen=True)
28 """Describe a MySensors binary sensor entity."""
30 is_on: Callable[[int, dict[int, str]], bool] = (
31 lambda value_type, values: values[value_type] ==
"1"
35 SENSORS: dict[str, MySensorsBinarySensorDescription] = {
38 device_class=BinarySensorDeviceClass.DOOR,
42 device_class=BinarySensorDeviceClass.MOTION,
46 device_class=BinarySensorDeviceClass.SMOKE,
50 device_class=BinarySensorDeviceClass.SAFETY,
54 device_class=BinarySensorDeviceClass.SAFETY,
58 device_class=BinarySensorDeviceClass.SOUND,
62 device_class=BinarySensorDeviceClass.VIBRATION,
66 device_class=BinarySensorDeviceClass.MOISTURE,
73 config_entry: ConfigEntry,
74 async_add_entities: AddEntitiesCallback,
76 """Set up this platform for a specific ConfigEntry(==Gateway)."""
80 """Discover and add a MySensors binary_sensor."""
83 Platform.BINARY_SENSOR,
85 MySensorsBinarySensor,
86 async_add_entities=async_add_entities,
91 config_entry.entry_id,
94 MYSENSORS_DISCOVERY.format(config_entry.entry_id, Platform.BINARY_SENSOR),
101 """Representation of a MySensors binary sensor child node."""
103 entity_description: MySensorsBinarySensorDescription
105 def __init__(self, *args: Any, **kwargs: Any) ->
None:
106 """Set up the instance."""
108 presentation = self.gateway.const.Presentation
113 """Return True if the binary sensor is on."""
None __init__(self, *Any args, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None on_unload(HomeAssistant hass, GatewayId gateway_id, Callable fnct)
None async_discover(DiscoveryInfo discovery_info)
list[MySensorsChildEntity]|None setup_mysensors_platform(HomeAssistant hass, Platform domain, DiscoveryInfo discovery_info, type[MySensorsChildEntity]|Mapping[SensorType, type[MySensorsChildEntity]] device_class,(tuple|None) device_args=None, Callable|None async_add_entities=None)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)