Camera demo
This commit is contained in:
1 parent
4eacea32da
commit
ca32c81612
6 files changed
+37
No files matched your search
@@ -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 |
Reference in new issue
Block a user