core/homeassistant/components/nest/camera.py

157 lines
4.6 KiB
Python
Raw Normal View History

"""Support for Nest Cameras."""
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
import logging
from datetime import timedelta
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
import requests
from homeassistant.components import nest
from homeassistant.components.camera import (PLATFORM_SCHEMA, Camera,
SUPPORT_ON_OFF)
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
from homeassistant.util.dt import utcnow
_LOGGER = logging.getLogger(__name__)
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
DEPENDENCIES = ['nest']
NEST_BRAND = 'Nest'
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({})
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a Nest Cam.
No longer in use.
"""
async def async_setup_entry(hass, entry, async_add_entities):
"""Set up a Nest sensor based on a config entry."""
camera_devices = \
await hass.async_add_job(hass.data[nest.DATA_NEST].cameras)
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
cameras = [NestCamera(structure, device)
for structure, device in camera_devices]
async_add_entities(cameras, True)
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
class NestCamera(Camera):
"""Representation of a Nest Camera."""
def __init__(self, structure, device):
"""Initialize a Nest Camera."""
super(NestCamera, self).__init__()
self.structure = structure
self.device = device
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
self._location = None
self._name = None
self._online = None
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
self._is_streaming = None
self._is_video_history_enabled = False
# Default to non-NestAware subscribed, but will be fixed during update
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
self._time_between_snapshots = timedelta(seconds=30)
self._last_image = None
self._next_snapshot_at = None
@property
def name(self):
"""Return the name of the nest, if any."""
return self._name
@property
def unique_id(self):
"""Return the serial number."""
return self.device.device_id
@property
def device_info(self):
"""Return information about the device."""
return {
'identifiers': {
(nest.DOMAIN, self.device.device_id)
},
'name': self.device.name_long,
'manufacturer': 'Nest Labs',
'model': "Camera",
}
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
@property
def should_poll(self):
"""Nest camera should poll periodically."""
return True
@property
def is_recording(self):
"""Return true if the device is recording."""
return self._is_streaming
@property
def brand(self):
"""Return the brand of the camera."""
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
return NEST_BRAND
@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
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
def update(self):
"""Cache value from Python-nest."""
self._location = self.device.where
self._name = self.device.name
self._online = self.device.online
self._is_streaming = self.device.is_streaming
self._is_video_history_enabled = self.device.is_video_history_enabled
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
if self._is_video_history_enabled:
# NestAware allowed 10/min
self._time_between_snapshots = timedelta(seconds=6)
else:
# Otherwise, 2/min
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
self._time_between_snapshots = timedelta(seconds=30)
def _ready_for_snapshot(self, now):
return (self._next_snapshot_at is None or
now > self._next_snapshot_at)
def camera_image(self):
"""Return a still image response from the camera."""
now = utcnow()
if self._ready_for_snapshot(now):
url = self.device.snapshot_url
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
try:
response = requests.get(url)
except requests.exceptions.RequestException as error:
_LOGGER.error("Error getting camera image: %s", error)
Nest Cam support (#4292) * start nestcam support * start nestcam support * introduce a access_token_cache_file * Bare minimum to get nest thermostat loading * occaisonally the image works * switch to nest-aware interval for testing * Add Nest Aware awareness * remove duplicate error logging line * Fix nest protect support * address baloobot * fix copy pasta * fix more baloobot * last baloobot thing for now? * Use streaming status to determine online or not. online from nest means its on the network * Fix temperature scale for climate * Add support for eco mode * Fix auto mode for nest climate * update update current_operation and set_operation mode to use constant when possible. try to get setting something working * remove stale comment * unused-argument already disabled globally * Add eco to the end, instead of after off * Simplify conditional when the hass mode is the same as the nest one * away_temperature became eco_temperature, and works with eco mode * Update min/max temp based on locked temperature * Forgot to set locked stuff during construction * Cache image instead of throttling (which returns none), respect NestAware subscription * Fix _time_between_snapshots before the first update * WIP pin authorization * Add some more logging * Working configurator, woo. Fix some hound errors * Updated pin workflow * Deprecate more sensors * Don't update during access of name * Don't update during access of name * Add camera brand * Fix up some syntastic errors * Fix ups ome hound errors * Maybe fix some more? * Move snapshot simulator url checking down into python-nest * Rename _ready_to_update_camera_image to _ready_for_snapshot * More fixes * Set the next time a snapshot can be taken when one is taken to simplify logic * Add a FIXME about update not getting called * Call update during constructor, so values get set at least once * Fix up names * Remove todo about eco, since that's pretty nest * thanks hound * Fix temperature being off for farenheight. * Fix some lint errors, which includes using a git version of python-nest with updated code * generate requirements_all.py * fix pylint * Update nestcam before adding * Fix polling of NestCamera * Lint
2016-11-28 00:18:47 +00:00
return None
self._next_snapshot_at = now + self._time_between_snapshots
self._last_image = response.content
return self._last_image