Skip to content
Snippets Groups Projects
Commit 30bd0dea authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Merge branch 'main' of gitlab.imt-atlantique.fr:xaal/code/python

parents 73ee2677 f3bf6bbc
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,8 @@ def value_is_command_class(value: Value, command_class: COMMAND_CLASS):
def value_is_value(value: Value):
return value.property_ in ["value", "currentValue"]
# return value.property_ in ["value", "currentValue", "targetValue"]
return value.property_ in ["targetValue"]
def build_devices(node: Node, eng: AsyncEngine):
......@@ -54,6 +55,9 @@ def build_devices(node: Node, eng: AsyncEngine):
if value_is_command_class(value, COMMAND_CLASS.SWITCH_BINARY):
obj = PowerRelay(node, value, base_addr)
if value_is_command_class(value, COMMAND_CLASS.SWITCH_MULTILEVEL):
obj = Lamp(node, value, base_addr)
if value_is_command_class(value, COMMAND_CLASS.METER):
obj = PowerMeter(node, value, base_addr)
pass
......@@ -61,6 +65,7 @@ def build_devices(node: Node, eng: AsyncEngine):
if obj is not None and obj.dev:
obj.setup()
eng.add_device(obj.dev)
logger.warning(obj.dev)
# if node.node_id == 5:
# pdb.set_trace()
......@@ -100,7 +105,6 @@ class PowerRelay(ZwaveDevice):
self.dev.attributes["power"] = value.value
async def turn_on(self):
pdb.set_trace()
await self.node.async_set_value(self.state, True)
async def turn_off(self):
......@@ -122,3 +126,20 @@ class PowerMeter(ZwaveDevice):
value = event['value']
if self.power == value:
self.dev.attributes["power"] = value.value
class Lamp(ZwaveDevice):
def __init__(self, node: Node, value: Value, base_addr: bindings.UUID):
super().__init__(node)
dev = devices.lamp(base_addr)
dev.methods["turn_on"] = self.turn_on
dev.methods["turn_off"] = self.turn_off
dev.attributes["light"] = value.value
self.dev = dev
self.state = value
async def turn_on(self):
await self.node.async_set_value(self.state, 99)
async def turn_off(self):
await self.node.async_set_value(self.state, 0)
......@@ -26,8 +26,8 @@ logger = logging.getLogger(__name__)
logging.getLogger("zwave_js_server").setLevel(logging.WARNING)
URL = "ws://10.77.3.143:3000"
# URL = "ws://localhost:3000"
# URL = "ws://10.77.3.143:3000"
URL = "ws://localhost:3000"
DEBUG = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment