hass-core/homeassistant/components/nest
Allen Porter a63fa53275
Persist nest media events to disk backed storage (#61641)
* Persist nest media events to disk backed storage

Persist nest events in the media player to disk, targeting about ~500mb
per camera device as a cap. Events are stored in config/nest/event_media/.

Add a NestEventMediaStore is used for persistence. It has three main jobs:
- Read/write the key/value data that holds event data (event type, time, device, etc)
- Read/write media contents to disk
- Pick the filename for the media event based on device and event deatils

The nest event media manager library handles cache management and eviction, and by
default uses an in memory cache. Home Assistant nest integration now provides the
disk backed implementation, which is invoked by the nest library.

The store reads the event metadata key/value dict on startup, and then writes it
back with a short delay of 5 seconds to avoid unnecessary writes.

Future work planned includes:
- Possibly a small memory buffer for media objects themselves. This could make sense
  when adding thumbnails to the media player grid to avoid unnecessary fetches
- Transcoding mp4 clips to animated image previews

* Address style errors

* Cleanup from CI test/pylint/etc.

* Put media for each device into its own directory

* Update comments for media store

* Decrease # of events to lower disk requirements

Target more like 1k events, to reduce disk needs.

* Address PR feedback

* Update homeassistant/components/nest/media_source.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Ignore incorrect mypy in nest library

* Fix pylint errors

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-12-18 23:53:40 -08:00
..
legacy Use new enums in nest (#61942) 2021-12-15 13:00:10 -08:00
translations [ci skip] Translation update 2021-12-15 00:13:42 +00:00
__init__.py Persist nest media events to disk backed storage (#61641) 2021-12-18 23:53:40 -08:00
api.py Update nest config flow to dramatically simplify end user setup with automated pub/sub subscription creation (#59260) 2021-11-29 22:41:29 -08:00
binary_sensor.py Increase static type coverage for nest integration (#53475) 2021-07-27 01:43:52 +02:00
camera.py Increase static type coverage for nest integration (#53475) 2021-07-27 01:43:52 +02:00
camera_sdm.py Revert "Add an entity service for saving nest event related snapshots" (#60632) 2021-11-30 16:16:00 +01:00
climate.py Increase static type coverage for nest integration (#53475) 2021-07-27 01:43:52 +02:00
climate_sdm.py Use assignment expressions 07 (#57787) 2021-10-17 20:24:34 +02:00
config_flow.py Update nest config flow to dramatically simplify end user setup with automated pub/sub subscription creation (#59260) 2021-11-29 22:41:29 -08:00
const.py Revert "Add an entity service for saving nest event related snapshots" (#60632) 2021-11-30 16:16:00 +01:00
device_info.py Use DeviceInfo Class N-O (#58314) 2021-10-24 11:34:45 +02:00
device_trigger.py Use assignment expressions 23 (#58180) 2021-10-22 11:13:05 +02:00
events.py Add Nest Battery Cam event clip support with a Nest MediaSource (#60073) 2021-12-03 10:53:05 -08:00
manifest.json Bump google-nest-sdm to 0.4.9 (#62160) 2021-12-17 09:07:51 +01:00
media_source.py Persist nest media events to disk backed storage (#61641) 2021-12-18 23:53:40 -08:00
placeholder.png Serve nest placeholder image from disk rather than generate on the fly (#58663) 2021-10-30 13:44:28 -07:00
sensor.py Increase static type coverage for nest integration (#53475) 2021-07-27 01:43:52 +02:00
sensor_sdm.py Use new enums in nest (#61942) 2021-12-15 13:00:10 -08:00
services.yaml Revert "Add an entity service for saving nest event related snapshots" (#60632) 2021-11-30 16:16:00 +01:00
strings.json Fix key reference placeholder (#60681) 2021-11-30 23:38:38 -08:00