Skip to content
Snippets Groups Projects
Commit e8d368c3 authored by jkerdreu's avatar jkerdreu
Browse files

Added support for motion sensors

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2973 b32b6428-25c9-4566-ad07-03861ab6144f
parent 660b6362
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ def xaal_loop(engine):
def random_devices():
tmp = {}
for k in ['button','contact','switch']:
for k in ['button','contact','switch','motion']:
uid = str(tools.get_random_uuid())
tmp[uid] = {'name':'fake %s' % k,'type':k}
return tmp
......@@ -70,6 +70,9 @@ def load_config(engine):
dev = devices.Switch(addr,name,engine)
if type_ == 'contact':
dev = devices.Contact(addr,name,engine)
if type_ == 'motion':
dev = devices.Motion(addr,name,engine)
if dev:
fake_devices.append(dev)
......
......@@ -6,8 +6,14 @@ class FakeDevice(object):
self.name = name
self.engine = engine
self.setup()
self._fix_description()
self.engine.add_device(self.dev)
def _fix_description(self):
dev = self.dev
dev.vendor_id = "RAMBo Team"
dev.product_id = f"Fake:{self.__class__.__name__ }"
class Button(FakeDevice):
def setup(self):
self.dev = devices.button(self.addr)
......@@ -46,3 +52,17 @@ class Contact(FakeDevice):
def state(self):
return 'checked' if self.dev.attributes['detected'] else ''
class Motion(FakeDevice):
def setup(self):
self.dev = devices.motion(self.addr)
def set_on(self):
self.dev.attributes['presence'] = True
def set_off(self):
self.dev.attributes['presence'] = False
@property
def state(self):
return 'checked' if self.dev.attributes['presence'] else ''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment