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:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user