This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+12 -11
View File
@@ -4,11 +4,16 @@ 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, 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
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
from homeassistant.loader import bind_hass
@@ -34,8 +39,7 @@ async def async_turn_on(hass, entity_id=None):
def enable_motion_detection(hass, entity_id=None):
"""Enable Motion Detection."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_ENABLE_MOTION, data))
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_ENABLE_MOTION, data))
@bind_hass
@@ -45,15 +49,12 @@ def async_snapshot(hass, filename, entity_id=None):
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
data[ATTR_FILENAME] = filename
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_SNAPSHOT, data))
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 = {PREF_PRELOAD_STREAM: True}
prefs_to_set.update(prefs)
hass.data[DATA_CAMERA_PREFS]._prefs[entity_id] = prefs_to_set
return prefs_to_set