mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Publish Nest Motion/Person events with optional user defined zone information (#66187)
Publish Nest events with zone information if present. User defined zones are configured in the Google Home app, and are published with Motion/Person event.
This commit is contained in:
parent
f344ea7bbb
commit
b2f5ab2008
@ -158,6 +158,8 @@ class SignalUpdateCallback:
|
|||||||
"timestamp": event_message.timestamp,
|
"timestamp": event_message.timestamp,
|
||||||
"nest_event_id": image_event.event_token,
|
"nest_event_id": image_event.event_token,
|
||||||
}
|
}
|
||||||
|
if image_event.zones:
|
||||||
|
message["zones"] = image_event.zones
|
||||||
self._hass.bus.async_fire(NEST_EVENT, message)
|
self._hass.bus.async_fire(NEST_EVENT, message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ NEST_EVENT = "nest_event"
|
|||||||
# "device_id": "my-device-id",
|
# "device_id": "my-device-id",
|
||||||
# "type": "camera_motion",
|
# "type": "camera_motion",
|
||||||
# "timestamp": "2021-10-24T19:42:43.304000+00:00",
|
# "timestamp": "2021-10-24T19:42:43.304000+00:00",
|
||||||
# "nest_event_id": "KcO1HIR9sPKQ2bqby_vTcCcEov..."
|
# "nest_event_id": "KcO1HIR9sPKQ2bqby_vTcCcEov...",
|
||||||
|
# "zones": ["Zone 1"],
|
||||||
# },
|
# },
|
||||||
# ...
|
# ...
|
||||||
# }
|
# }
|
||||||
|
@ -28,7 +28,7 @@ NEST_EVENT = "nest_event"
|
|||||||
EVENT_SESSION_ID = "CjY5Y3VKaTZwR3o4Y19YbTVfMF..."
|
EVENT_SESSION_ID = "CjY5Y3VKaTZwR3o4Y19YbTVfMF..."
|
||||||
EVENT_ID = "FWWVQVUdGNUlTU2V4MGV2aTNXV..."
|
EVENT_ID = "FWWVQVUdGNUlTU2V4MGV2aTNXV..."
|
||||||
|
|
||||||
EVENT_KEYS = {"device_id", "type", "timestamp"}
|
EVENT_KEYS = {"device_id", "type", "timestamp", "zones"}
|
||||||
|
|
||||||
|
|
||||||
def event_view(d: Mapping[str, Any]) -> Mapping[str, Any]:
|
def event_view(d: Mapping[str, Any]) -> Mapping[str, Any]:
|
||||||
@ -514,3 +514,37 @@ async def test_structure_update_event(hass):
|
|||||||
assert registry.async_get("camera.front")
|
assert registry.async_get("camera.front")
|
||||||
# Currently need a manual reload to detect the new entity
|
# Currently need a manual reload to detect the new entity
|
||||||
assert not registry.async_get("camera.back")
|
assert not registry.async_get("camera.back")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_event_zones(hass):
|
||||||
|
"""Test events published with zone information."""
|
||||||
|
events = async_capture_events(hass, NEST_EVENT)
|
||||||
|
subscriber = await async_setup_devices(
|
||||||
|
hass,
|
||||||
|
"sdm.devices.types.DOORBELL",
|
||||||
|
create_device_traits(["sdm.devices.traits.CameraMotion"]),
|
||||||
|
)
|
||||||
|
registry = er.async_get(hass)
|
||||||
|
entry = registry.async_get("camera.front")
|
||||||
|
assert entry is not None
|
||||||
|
|
||||||
|
event_map = {
|
||||||
|
"sdm.devices.events.CameraMotion.Motion": {
|
||||||
|
"eventSessionId": EVENT_SESSION_ID,
|
||||||
|
"eventId": EVENT_ID,
|
||||||
|
"zones": ["Zone 1"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamp = utcnow()
|
||||||
|
await subscriber.async_receive_event(create_events(event_map, timestamp=timestamp))
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
event_time = timestamp.replace(microsecond=0)
|
||||||
|
assert len(events) == 1
|
||||||
|
assert event_view(events[0].data) == {
|
||||||
|
"device_id": entry.device_id,
|
||||||
|
"type": "camera_motion",
|
||||||
|
"timestamp": event_time,
|
||||||
|
"zones": ["Zone 1"],
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user