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
import asyncio
import base64
from datetime import datetime, timezone
from datetime import datetime
import random
from typing import TYPE_CHECKING, Any, cast
@ -262,10 +262,6 @@ class AmcrestAPIMixin:
self.upsert_state(
device_id,
image={"snapshot": encoded},
sensor={
"event_text": "Got snapshot",
"event_time": datetime.now(timezone.utc).isoformat(),
},
)
self.publish_device_state(device_id)

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

Loading…
Cancel
Save