mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Allow Nest Cam turn on/off (#15681)
* Allow Nest Cam turn on/off * Don't raise Error * Remove unnecessary state update
This commit is contained in:
parent
1c42caba76
commit
9fb8bc8991
@ -10,7 +10,8 @@ from datetime import timedelta
|
||||
import requests
|
||||
|
||||
from homeassistant.components import nest
|
||||
from homeassistant.components.camera import (PLATFORM_SCHEMA, Camera)
|
||||
from homeassistant.components.camera import (PLATFORM_SCHEMA, Camera,
|
||||
SUPPORT_ON_OFF)
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -76,7 +77,36 @@ class NestCamera(Camera):
|
||||
"""Return the brand of the camera."""
|
||||
return NEST_BRAND
|
||||
|
||||
# This doesn't seem to be getting called regularly, for some reason
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Nest Cam support turn on and off."""
|
||||
return SUPPORT_ON_OFF
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if on."""
|
||||
return self._online and self._is_streaming
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn off camera."""
|
||||
_LOGGER.debug('Turn off camera %s', self._name)
|
||||
# Calling Nest API in is_streaming setter.
|
||||
# device.is_streaming would not immediately change until the process
|
||||
# finished in Nest Cam.
|
||||
self.device.is_streaming = False
|
||||
|
||||
def turn_on(self):
|
||||
"""Turn on camera."""
|
||||
if not self._online:
|
||||
_LOGGER.error('Camera %s is offline.', self._name)
|
||||
return
|
||||
|
||||
_LOGGER.debug('Turn on camera %s', self._name)
|
||||
# Calling Nest API in is_streaming setter.
|
||||
# device.is_streaming would not immediately change until the process
|
||||
# finished in Nest Cam.
|
||||
self.device.is_streaming = True
|
||||
|
||||
def update(self):
|
||||
"""Cache value from Python-nest."""
|
||||
self._location = self.device.where
|
||||
|
Loading…
x
Reference in New Issue
Block a user