File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
homeassistant/components/hue/v2 Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,11 @@ def is_on(self) -> bool | None:
145145 if not self .resource .enabled :
146146 # Force None (unknown) if the sensor is set to disabled in Hue
147147 return None
148- return self .resource .motion .value
148+ if not (motion_feature := self .resource .motion ):
149+ return None
150+ if motion_feature .motion_report is not None :
151+ return motion_feature .motion_report .motion
152+ return motion_feature .motion
149153
150154
151155# pylint: disable-next=hass-enforce-class-module
Original file line number Diff line number Diff line change @@ -123,6 +123,29 @@ async def test_binary_sensor_add_update(
123123 test_entity = hass .states .get (test_entity_id )
124124 assert test_entity is not None
125125 assert test_entity .state == "on"
126+ # NEW: prefer motion_report.motion when present (should turn on even if plain motion is False)
127+ updated_sensor = {
128+ ** FAKE_BINARY_SENSOR ,
129+ "motion" : {
130+ "motion" : False ,
131+ "motion_report" : {"changed" : "2025-01-01T00:00:00Z" , "motion" : True },
132+ },
133+ }
134+ mock_bridge_v2 .api .emit_event ("update" , updated_sensor )
135+ await hass .async_block_till_done ()
136+ assert hass .states .get (test_entity_id ).state == "on"
137+
138+ # NEW: motion_report False should turn it off (even if plain motion is True)
139+ updated_sensor = {
140+ ** FAKE_BINARY_SENSOR ,
141+ "motion" : {
142+ "motion" : True ,
143+ "motion_report" : {"changed" : "2025-01-01T00:00:01Z" , "motion" : False },
144+ },
145+ }
146+ mock_bridge_v2 .api .emit_event ("update" , updated_sensor )
147+ await hass .async_block_till_done ()
148+ assert hass .states .get (test_entity_id ).state == "off"
126149
127150
128151async def test_grouped_motion_sensor (
You can’t perform that action at this time.
0 commit comments