1 """Platform for binarysensor integration."""
3 from __future__
import annotations
5 from boschshcpy
import SHCBatteryDevice, SHCSession, SHCShutterContact
6 from boschshcpy.device
import SHCDevice
9 BinarySensorDeviceClass,
16 from .const
import DATA_SESSION, DOMAIN
17 from .entity
import SHCEntity
22 config_entry: ConfigEntry,
23 async_add_entities: AddEntitiesCallback,
25 """Set up the SHC binary sensor platform."""
26 session: SHCSession = hass.data[DOMAIN][config_entry.entry_id][DATA_SESSION]
28 entities: list[BinarySensorEntity] = [
31 parent_id=session.information.unique_id,
32 entry_id=config_entry.entry_id,
34 for binary_sensor
in (
35 session.device_helper.shutter_contacts
36 + session.device_helper.shutter_contacts2
43 parent_id=session.information.unique_id,
44 entry_id=config_entry.entry_id,
46 for binary_sensor
in (
47 session.device_helper.motion_detectors
48 + session.device_helper.shutter_contacts
49 + session.device_helper.shutter_contacts2
50 + session.device_helper.smoke_detectors
51 + session.device_helper.thermostats
52 + session.device_helper.twinguards
53 + session.device_helper.universal_switches
54 + session.device_helper.wallthermostats
55 + session.device_helper.water_leakage_detectors
63 """Representation of an SHC shutter contact sensor."""
67 def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) ->
None:
68 """Initialize an SHC shutter contact sensor.."""
69 super().
__init__(device, parent_id, entry_id)
71 "ENTRANCE_DOOR": BinarySensorDeviceClass.DOOR,
72 "REGULAR_WINDOW": BinarySensorDeviceClass.WINDOW,
73 "FRENCH_WINDOW": BinarySensorDeviceClass.DOOR,
74 "GENERIC": BinarySensorDeviceClass.WINDOW,
77 self.
_device_device.device_class, BinarySensorDeviceClass.WINDOW
82 """Return the state of the sensor."""
83 return self.
_device_device.state == SHCShutterContact.ShutterContactService.State.OPEN
87 """Representation of an SHC battery reporting sensor."""
89 _attr_device_class = BinarySensorDeviceClass.BATTERY
91 def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) ->
None:
92 """Initialize an SHC battery reporting sensor."""
93 super().
__init__(device, parent_id, entry_id)
98 """Return the state of the sensor."""
100 self.
_device_device.batterylevel != SHCBatteryDevice.BatteryLevelService.State.OK
None __init__(self, SHCDevice device, str parent_id, str entry_id)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)