File tree Expand file tree Collapse file tree
custom_components/wasp_in_a_box Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9898 seconds: 0
9999```
100100
101+ - For advanced automations the state of the motion and door sensors are exposed as attributes within the binary sensor.
102+
101103---
102104
103105[ commits-shield ] : https://img.shields.io/github/commit-activity/y/andrew-codechimp/HA-Wasp-In-A-Box.svg?style=for-the-badge
Original file line number Diff line number Diff line change 2525)
2626
2727from .const import (
28+ ATTR_DOOR_SENSOR_STATE ,
29+ ATTR_MOTION_SENSOR_STATE ,
2830 CONF_BOX_ID ,
2931 CONF_DOOR_CLOSED_DELAY ,
3032 CONF_DOOR_OPEN_TIMEOUT ,
@@ -70,6 +72,7 @@ class WaspInABoxSensor(BinarySensorEntity):
7072
7173 _attr_device_class = BinarySensorDeviceClass .OCCUPANCY
7274 _attr_should_poll = False
75+ _attr_translation_key = "wasp_in_a_box"
7376 _state_had_real_change = False
7477 _wasp_state : str = STATE_UNKNOWN
7578 _box_state : str = STATE_UNKNOWN
@@ -179,6 +182,14 @@ def is_on(self) -> bool | None:
179182 # Convert state to boolean - "on" means occupied
180183 return self ._state == STATE_ON
181184
185+ @property
186+ def extra_state_attributes (self ) -> dict [str , str ]:
187+ """Return state attributes."""
188+ return {
189+ ATTR_MOTION_SENSOR_STATE : self ._wasp_state ,
190+ ATTR_DOOR_SENSOR_STATE : self ._box_state ,
191+ }
192+
182193 @callback
183194 def _async_wasp_state_listener (self , event : Event [EventStateChangedData ]) -> None :
184195 """Handle the wasp sensor state changes."""
Original file line number Diff line number Diff line change 2121DEFAULT_DOOR_CLOSED_DELAY = 30
2222DEFAULT_OPEN_DOOR_TIMEOUT = 300
2323DEFAULT_IMMEDIATE_ON = True
24+
25+ ATTR_MOTION_SENSOR_STATE = "motion_sensor_state"
26+ ATTR_DOOR_SENSOR_STATE = "door_sensor_state"
Original file line number Diff line number Diff line change 4141 }
4242 }
4343 }
44+ },
45+ "entity" : {
46+ "binary_sensor" : {
47+ "wasp_in_a_box" : {
48+ "state_attributes" : {
49+ "motion_sensor_state" : {
50+ "name" : " Motion sensor state" ,
51+ "state" : {
52+ "on" : " Motion detected" ,
53+ "off" : " No motion" ,
54+ "unknown" : " Unknown"
55+ }
56+ },
57+ "door_sensor_state" : {
58+ "name" : " Door sensor state" ,
59+ "state" : {
60+ "on" : " Open" ,
61+ "off" : " Closed" ,
62+ "unknown" : " Unknown"
63+ }
64+ }
65+ }
66+ }
67+ }
4468 }
4569}
You can’t perform that action at this time.
0 commit comments