Commit Graph

66 Commits

Author SHA1 Message Date
Blake Blackshear
de811b7018 delete clean snapshot when duplicate 2021-10-02 06:59:02 -05:00
Blake Blackshear
1d25936f31 add region/bbox/area to event table 2021-09-23 07:31:48 -05:00
Blake Blackshear
1b2134c49e remove clip_ready event type
this doesnt really mean anything more than "end" anymore. new has_clip property added
2021-09-15 07:16:52 -05:00
Blake Blackshear
89e317a6bb store start/end event with pre/post capture to avoid expiring wanted recordings 2021-09-11 08:34:27 -05:00
Blake Blackshear
288b1a0562 remove nested enabled config setting on events 2021-09-08 08:02:26 -05:00
Blake Blackshear
2181379475 stop using pycoral libs for efficiency 2021-08-15 09:14:13 -05:00
Blake Blackshear
b33f4e2dc6 assume the clip for the event exists with recordings 2021-08-12 06:42:44 -05:00
Jason Hunter
5d94c68d66 fix recording retention logic 2021-08-07 15:51:16 -05:00
Jason Hunter
a476bc9885 initial commit 2021-08-07 15:51:16 -05:00
Blake Blackshear
09b0068d16 fix cache cleanup (fixes #1231) 2021-06-30 06:38:36 -05:00
Blake Blackshear
d66f5f6bad cleanup clean snapshots 2021-06-19 08:49:06 -05:00
gpete
b72b66781a
Fixed overwritten argument 'media' (#1026)
media variable name is reused and overwritten causing issues with event expiration & clean up.
Also changed name in pure_duplicates for consistency.
2021-06-19 07:11:43 -05:00
Blake Blackshear
3b695040d1 send clip_ready mqtt to event topic 2021-06-14 18:20:12 -05:00
Sean Vig
84a0827aee Use dataclasses for config handling
Use config data classes to eliminate some of the boilerplate associated
with setting up the configuration.  In particular, using dataclasses
removes a lot of the boilerplate around assigning properties to the
object and allows these to be easily immutable by freezing them.  In the
case of simple, non-nested dataclasses, this also provides more
convenient `asdict` helpers.

To set this up, where previously the objects would be parsed from the
config via the `__init__` method, create a `build` classmethod that does
this and calls the dataclass initializer.

Some of the objects are mutated at runtime, in particular some of the
zones are mutated to set the color (this might be able to be refactored
out) and some of the camera functionality can be enabled/disabled.  Some
of the configs with `enabled` properties don't seem to have mqtt hooks
to be able to toggle this, in particular, the clips, snapshots, and
detect can be toggled but rtmp and record configs do not, but all of
these configs are still not frozen in case there is some other
functionality I am missing.

There are a couple other minor fixes here, one that was introduced
by me recently where `max_seconds` was not defined, the other to
properly `get()` the message payload when handling publishing mqtt
messages sent via websocket.
2021-05-23 20:38:57 -05:00
Blake Blackshear
1fbcf4d9b9 fixes 2021-05-23 08:21:18 -05:00
Sean Vig
57864f2be6 Wait on stop event when possible
Generally eliminate the `while True` loops while waiting for a stop
event and prefer to condition the loops on if the stop event is set,
blocking on that where it makes sense.  This generally comes in 3
flavors.  First and simplest, when there is a sleep and the stop event
is the only thing the loop blocks on, instead do a check using
`stop_event.wait(timeout)` to instead block on the stop event for the
designated amount of time. Second, when there is a different event that
is blocking in the loop, condition the loop on `stop_event.is_set()`
rather than breaking when it is set. Finally, when there is a separate
internal condition that requires a counter, have the loop iterate over
the counter and use `if stop_event.wait(timeout)` internal to the loop.
2021-05-22 07:54:16 -05:00
Sean Vig
a4e6d9ed9a Improve ffprobe executions
When running ffprobe, use `subprocess.run` rather than
`subprocess.Popen`.  This simplifies the handling that is needed to run
and process the outputs.  Here, filename parsing is also simplified by
explicitly removing the file extension with `os.path.splitext` and
forcing a single split into the camera name and the formatted date.
2021-05-22 07:48:00 -05:00
Blake Blackshear
39ff49e054 formatting cleanup 2021-02-25 07:01:57 -06:00
Blake Blackshear
a661fddaf3 fix cache cleanup for large full disks 2021-02-20 08:20:17 -06:00
Blake Blackshear
1b85e561b9 only save the event to the database if a snapshot or clip exists 2021-02-20 08:20:17 -06:00
Blake Blackshear
165ca8fbc7 purge duplicate events during cleanup 2021-02-20 08:20:17 -06:00
Blake Blackshear
121ea37825 allow defining required zones for snapshots/clips/mqtt 2021-02-20 08:20:17 -06:00
Blake Blackshear
9592d95599 proactively clean up cache when above 90% use 2021-02-20 08:20:17 -06:00
Blake Blackshear
d31c295598 add debug log when cache is cleaned up 2021-01-26 21:40:33 -06:00
Blake Blackshear
2885b80a13 dont wait forever for the cache 2021-01-26 21:40:33 -06:00
Blake Blackshear
3fab321045 update object filters to inherit like motion settings 2021-01-26 21:40:33 -06:00
Blake Blackshear
63e14a98f9 add retention settings for snapshots 2021-01-26 21:40:33 -06:00
Blake Blackshear
89e3c2e4b1 store has_clip and has_snapshot on events 2021-01-26 21:40:33 -06:00
Blake Blackshear
e5399ae07a enable turning clips on and off via mqtt 2021-01-26 21:40:33 -06:00
Blake Blackshear
80a5a7b129 cleanup save_Clips/clips inconsistency 2021-01-26 21:40:33 -06:00
Blake Blackshear
2cc9a15f6a handle scenario with empty cache 2021-01-26 21:40:33 -06:00
Blake Blackshear
8d52e2635a optimize clips fixes #299 2021-01-26 21:40:33 -06:00
Blake Blackshear
f20e1f20a6 add post_capture option 2021-01-26 21:40:33 -06:00
Blake Blackshear
e147852878 catch all psutil errors 2021-01-26 21:40:33 -06:00
Blake Blackshear
62728ef7fb default save_clips objects 2021-01-26 21:40:33 -06:00
Blake Blackshear
735cc3962b make directories constants 2021-01-26 21:40:33 -06:00
Blake Blackshear
feb42181de cleanup empty directories 2021-01-26 21:40:33 -06:00
Blake Blackshear
4e0cf3681e add multiple streams per camera 2021-01-26 21:40:33 -06:00
Blake Blackshear
34d9b2983e ensure all events are cleaned up 2021-01-26 21:40:33 -06:00
Blake Blackshear
60207723d1 pull from memory if event in progress 2021-01-26 21:40:33 -06:00
Blake Blackshear
e9ecc20a36 sleep in the right place 2021-01-26 21:40:33 -06:00
Blake Blackshear
addfa2a32d manage events for unlisted cameras 2021-01-26 21:40:33 -06:00
Blake Blackshear
0dad9bc393 add event cleanup thread 2021-01-26 21:40:33 -06:00
Blake Blackshear
00c75e9f98 only save events when a clip is created 2021-01-26 21:40:33 -06:00
Blake Blackshear
1b5b02d286 add bas64 encoded thumbnail to the database 2021-01-26 21:40:33 -06:00
Blake Blackshear
3941ce4ad1 stop writing json file to disk 2021-01-26 21:40:33 -06:00
Blake Blackshear
03c855ecbe sort imports 2021-01-26 21:40:33 -06:00
Blake Blackshear
3a3cb24631 naming threads and processes for logs 2021-01-26 21:40:33 -06:00
Blake Blackshear
4c3fea25a5 use a queue for logging 2021-01-26 21:40:33 -06:00
Blake Blackshear
af303cbf2a create typed config classes 2021-01-26 21:40:33 -06:00