1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Camera Preferences + Preload Stream (#22339)

* initial commit for camera preferences and preload stream

* cleanup and add tests

* respect camera preferences on each request stream call

* return the new prefs after update
This commit is contained in:
Jason Hunter
2019-03-26 08:31:29 -04:00
committed by GitHub
parent baa4945944
commit bad0a8b342
11 changed files with 252 additions and 22 deletions

View File

@@ -4,7 +4,9 @@ All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.camera import (
ATTR_FILENAME, DOMAIN, SERVICE_ENABLE_MOTION, SERVICE_SNAPSHOT)
ATTR_FILENAME, SERVICE_ENABLE_MOTION, SERVICE_SNAPSHOT)
from homeassistant.components.camera.const import (
DOMAIN, DATA_CAMERA_PREFS, PREF_PRELOAD_STREAM)
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, \
SERVICE_TURN_ON
from homeassistant.core import callback
@@ -45,3 +47,13 @@ def async_snapshot(hass, filename, entity_id=None):
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_SNAPSHOT, data))
def mock_camera_prefs(hass, entity_id, prefs={}):
"""Fixture for cloud component."""
prefs_to_set = {
PREF_PRELOAD_STREAM: True,
}
prefs_to_set.update(prefs)
hass.data[DATA_CAMERA_PREFS]._prefs[entity_id] = prefs_to_set
return prefs_to_set