Merge pull request #636 from fabaff/camera-demo

Camera demo
This commit is contained in:
Paulus Schoutsen 2015-11-19 12:11:12 -08:00
commit 6d315a1a7c
7 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,37 @@
"""
homeassistant.components.camera.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has a fake camera.
"""
import os
from random import randint
from homeassistant.components.camera import Camera
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo camera. """
add_devices([
DemoCamera('Demo camera')
])
class DemoCamera(Camera):
""" A Demo camera. """
def __init__(self, name):
super().__init__()
self._name = name
def camera_image(self):
""" Return a faked still image response. """
image_path = os.path.join(os.path.dirname(__file__),
'demo_{}.png'.format(randint(1, 5)))
with open(image_path, 'rb') as file:
output = file.read()
return output
@property
def name(self):
""" Return the name of this device. """
return self._name

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -18,7 +18,7 @@ DEPENDENCIES = ['conversation', 'introduction', 'zone']
COMPONENTS_WITH_DEMO_PLATFORM = [
'device_tracker', 'light', 'media_player', 'notify', 'switch', 'sensor',
'thermostat']
'thermostat', 'camera']
def setup(hass, config):