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

ZwaveJS API digging

Spent a lot of time w/ testing some stuff with the ZwaveJS API. It is
really hard to deal w/. The old Openzwave was a pain, but this is not
really better. OpenZwave lacks some docs, but this one looks
inconsistent ;(
parent fec899c3
No related branches found
No related tags found
No related merge requests found
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)
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