Support for August doorbell (#11124)
* Add support for August doorbell * Address PR comment for August platform * Address PR comment for August binary sensor * Address PR comment for August camera * Addressed PR comment for August lock * - Fixed houndci-bot error * - Updated configurator description * - Fixed stale docstring * Added august module to .coveragerc
This commit is contained in:
parent
e8d8b75c07
commit
a8444b22e7
6 changed files with 518 additions and 0 deletions
76
homeassistant/components/camera/august.py
Normal file
76
homeassistant/components/camera/august.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
"""
|
||||
Support for August camera.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/camera.august/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
|
||||
import requests
|
||||
|
||||
from homeassistant.components.august import DATA_AUGUST, DEFAULT_TIMEOUT
|
||||
from homeassistant.components.camera import Camera
|
||||
|
||||
DEPENDENCIES = ['august']
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=5)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up August cameras."""
|
||||
data = hass.data[DATA_AUGUST]
|
||||
devices = []
|
||||
|
||||
for doorbell in data.doorbells:
|
||||
devices.append(AugustCamera(data, doorbell, DEFAULT_TIMEOUT))
|
||||
|
||||
add_devices(devices, True)
|
||||
|
||||
|
||||
class AugustCamera(Camera):
|
||||
"""An implementation of a Canary security camera."""
|
||||
|
||||
def __init__(self, data, doorbell, timeout):
|
||||
"""Initialize a Canary security camera."""
|
||||
super().__init__()
|
||||
self._data = data
|
||||
self._doorbell = doorbell
|
||||
self._timeout = timeout
|
||||
self._image_url = None
|
||||
self._image_content = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of this device."""
|
||||
return self._doorbell.device_name
|
||||
|
||||
@property
|
||||
def is_recording(self):
|
||||
"""Return true if the device is recording."""
|
||||
return self._doorbell.has_subscription
|
||||
|
||||
@property
|
||||
def motion_detection_enabled(self):
|
||||
"""Return the camera motion detection status."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def brand(self):
|
||||
"""Return the camera brand."""
|
||||
return 'August'
|
||||
|
||||
@property
|
||||
def model(self):
|
||||
"""Return the camera model."""
|
||||
return 'Doorbell'
|
||||
|
||||
def camera_image(self):
|
||||
"""Return bytes of camera image."""
|
||||
latest = self._data.get_doorbell_detail(self._doorbell.device_id)
|
||||
|
||||
if self._image_url is not latest.image_url:
|
||||
self._image_url = latest.image_url
|
||||
self._image_content = requests.get(self._image_url,
|
||||
timeout=self._timeout).content
|
||||
|
||||
return self._image_content
|
Loading…
Add table
Add a link
Reference in a new issue