1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Fix for Hue Integration motion aware areas (#153079)

Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Kyle Worrall
2025-09-29 05:50:36 -07:00
committed by GitHub
parent 0a6fa978fa
commit aa4151ced7
2 changed files with 28 additions and 1 deletions

View File

@@ -145,7 +145,11 @@ class HueMotionSensor(HueBaseEntity, BinarySensorEntity):
if not self.resource.enabled:
# Force None (unknown) if the sensor is set to disabled in Hue
return None
return self.resource.motion.value
if not (motion_feature := self.resource.motion):
return None
if motion_feature.motion_report is not None:
return motion_feature.motion_report.motion
return motion_feature.motion
# pylint: disable-next=hass-enforce-class-module

View File

@@ -123,6 +123,29 @@ async def test_binary_sensor_add_update(
test_entity = hass.states.get(test_entity_id)
assert test_entity is not None
assert test_entity.state == "on"
# NEW: prefer motion_report.motion when present (should turn on even if plain motion is False)
updated_sensor = {
**FAKE_BINARY_SENSOR,
"motion": {
"motion": False,
"motion_report": {"changed": "2025-01-01T00:00:00Z", "motion": True},
},
}
mock_bridge_v2.api.emit_event("update", updated_sensor)
await hass.async_block_till_done()
assert hass.states.get(test_entity_id).state == "on"
# NEW: motion_report False should turn it off (even if plain motion is True)
updated_sensor = {
**FAKE_BINARY_SENSOR,
"motion": {
"motion": True,
"motion_report": {"changed": "2025-01-01T00:00:01Z", "motion": False},
},
}
mock_bridge_v2.api.emit_event("update", updated_sensor)
await hass.async_block_till_done()
assert hass.states.get(test_entity_id).state == "off"
async def test_grouped_motion_sensor(