diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py index 5944baff34722d627cdfbef338631d3fbab690bd..62dd1b06ecba2f6f95c3192277ab6b73361fffa3 100644 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py @@ -55,7 +55,7 @@ def build_devices(node: Node, eng: AsyncEngine): obj = PowerRelay(node, value, base_addr) if value_is_command_class(value, COMMAND_CLASS.METER): - # obj = PowerMeter(node, value, base_addr) + obj = PowerMeter(node, value, base_addr) pass if obj is not None and obj.dev: @@ -79,7 +79,7 @@ class ZwaveDevice(object): dev.info = f"{self.node.node_id}" self.node.on(const.EVT_VALUE_UPDATED, self.update) - def update(self, event: Event): + def update(self, event: dict): print(event) @@ -93,7 +93,7 @@ class PowerRelay(ZwaveDevice): self.dev = dev self.state = value - def update(self, event: Event): + def update(self, event: dict): if self.dev: value = event['value'] if self.state == value: @@ -111,5 +111,14 @@ class PowerMeter(ZwaveDevice): def __init__(self, node: Node, value: Value, base_addr: bindings.UUID): super().__init__(node) self.state = value - self.dev = devices.powermeter(base_addr) - self.dev.unsupported_attributes = ['devices'] + dev = devices.powermeter(base_addr) + dev.unsupported_attributes = ['devices'] + dev.attributes['power'] = value.value + self.dev = dev + self.power = value + + def update(self, event: dict): + if self.dev: + value = event['value'] + if self.power == value: + self.dev.attributes["power"] = value.value