diff --git a/homeassistant/components/camera/nest.py b/homeassistant/components/camera/nest.py index fcd9b7e8a074fc..bf6700371fd26f 100644 --- a/homeassistant/components/camera/nest.py +++ b/homeassistant/components/camera/nest.py @@ -10,7 +10,8 @@ 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 @@ def brand(self): """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