diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py index 50ada5d0d22c06f6843840fceab07ab9bd657204..f405889415a855bf9e76a0a86cfa333dbe6f551f 100644 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py @@ -1,22 +1,44 @@ from xaal.schemas import devices from zwave_js_server.model.node import Node +from zwave_js_server.model.value import Value from zwave_js_server.event import Event from logging import getLogger +from .cmdclass import COMMAND_CLASS + +import pdb + + logger = getLogger(__name__) +def get_property_id(value: Value): + if value.property_ in ["value", "currentValue", "targetValue"]: + return value.property_key_name + return "--" + str(value.property_name) + + +def dump_value(value: Value): + print(f"[{value}] {'0x%x'%value.command_class} {value.endpoint} {get_property_id(value)} => {value.value}") + + def build_devices(node: Node): - logger.warning(f"{node.node_id} {node.device_config.manufacturer}/{node.device_config.label} ") + config = node.device_config + logger.info(f"{node.node_id} {config.manufacturer}/{config.label} ") # node.on("value updated", self.value_updated) # pdb.set_trace() for k in node.values: value = node.values.get(k) - if value: - print(f"[{k}] {value.endpoint} {value.property_name} => {value.value}") - # pprint(node.data) + assert value + if value.command_class == COMMAND_CLASS.SWITCH_BINARY.value and value.property_ == 'currentValue': + dump_value(value) + if value.command_class == COMMAND_CLASS.METER.value and value.property_ == 'value': + dump_value(value) + + # if node.node_id == 5: + # pdb.set_trace() class ZwaveDevice(object): @@ -40,6 +62,7 @@ class PowerMeter(ZwaveDevice): def __init__(self, node): super().__init__(node) self.dev = devices.powermeter() + self.dev.unsupported_attributes = ['devices'] def update(self, event: Event): print(event)