refactor: only record specific events as events, not snapshots for example

pull/106/head
Jeff Culverhouse 3 months ago
parent 114073e465
commit 8e12793ae0

@ -4,7 +4,7 @@ from amcrest import AmcrestCamera
from amcrest.exceptions import LoginError, AmcrestError, CommError from amcrest.exceptions import LoginError, AmcrestError, CommError
import asyncio import asyncio
import base64 import base64
from datetime import datetime, timezone from datetime import datetime
import random import random
from typing import TYPE_CHECKING, Any, cast from typing import TYPE_CHECKING, Any, cast
@ -262,10 +262,6 @@ class AmcrestAPIMixin:
self.upsert_state( self.upsert_state(
device_id, device_id,
image={"snapshot": encoded}, image={"snapshot": encoded},
sensor={
"event_text": "Got snapshot",
"event_time": datetime.now(timezone.utc).isoformat(),
},
) )
self.publish_device_state(device_id) self.publish_device_state(device_id)

@ -61,9 +61,7 @@ class EventsMixin:
if event in ["motion", "human", "doorbell"] and states["switch"]["privacy"] != "OFF": if event in ["motion", "human", "doorbell"] and states["switch"]["privacy"] != "OFF":
self.upsert_state(device_id, switch={"privacy_mode": "OFF"}) self.upsert_state(device_id, switch={"privacy_mode": "OFF"})
# send most everything to the device's event_text/time # record just these "events": text and time
if event not in ["NTPAdjustTime"]:
self.logger.debug(f'got event {{{event}: {payload}}} for "{self.get_device_name(device_id)}"')
self.upsert_state( self.upsert_state(
device_id, device_id,
sensor={ sensor={
@ -72,6 +70,8 @@ class EventsMixin:
}, },
) )
needs_publish.add(device_id) needs_publish.add(device_id)
else:
self.logger.info(f'Ignored event for "{self.get_device_name(device_id)}": {event} with {payload}')
for id in needs_publish: for id in needs_publish:
self.publish_device_state(id) self.publish_device_state(id)

Loading…
Cancel
Save