Camera demo
This commit is contained in:
parent
4eacea32da
commit
ca32c81612
6 changed files with 37 additions and 0 deletions
37
homeassistant/components/camera/demo.py
Normal file
37
homeassistant/components/camera/demo.py
Normal 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
|
BIN
homeassistant/components/camera/demo_1.png
Normal file
BIN
homeassistant/components/camera/demo_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
homeassistant/components/camera/demo_2.png
Normal file
BIN
homeassistant/components/camera/demo_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
BIN
homeassistant/components/camera/demo_3.png
Normal file
BIN
homeassistant/components/camera/demo_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
BIN
homeassistant/components/camera/demo_4.png
Normal file
BIN
homeassistant/components/camera/demo_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
BIN
homeassistant/components/camera/demo_5.png
Normal file
BIN
homeassistant/components/camera/demo_5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
Loading…
Add table
Add a link
Reference in a new issue