Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Nest Cam turn on/off #15681

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 32 additions & 2 deletions homeassistant/components/camera/nest.py
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand Down