diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py b/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py new file mode 100644 index 0000000000000000000000000000000000000000..967ba08a59bc7b6f6abcc6b89a77fc1a69852e39 --- /dev/null +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py @@ -0,0 +1,104 @@ +from enum import Enum + +class COMMAND_CLASS(Enum): + NO_OPERATION = 0x00 + BASIC = 0x20 + CONTROLLER_REPLICATION = 0x21 + APPLICATION_STATUS = 0x22 + ZIP_SERVICES = 0x23 + ZIP_SERVER = 0x24 + SWITCH_BINARY = 0x25 + SWITCH_MULTILEVEL = 0x26 + SWITCH_MULTILEVEL_V2 = 0x26 + SWITCH_ALL = 0x27 + SWITCH_TOGGLE_BINARY = 0x28 + SWITCH_TOGGLE_MULTILEVEL = 0x29 + CHIMNEY_FAN = 0x2A + SCENE_ACTIVATION = 0x2B + SCENE_ACTUATOR_CONF = 0x2C + SCENE_CONTROLLER_CONF = 0x2D + ZIP_CLIENT = 0x2E + ZIP_ADV_SERVICES = 0x2F + SENSOR_BINARY = 0x30 + SENSOR_MULTILEVEL = 0x31 + SENSOR_MULTILEVEL_V2 = 0x31 + METER = 0x32 + ZIP_ADV_SERVER = 0x33 + ZIP_ADV_CLIENT = 0x34 + METER_PULSE = 0x35 + METER_TBL_CONFIG = 0x3C + METER_TBL_MONITOR = 0x3D + METER_TBL_PUSH = 0x3E + THERMOSTAT_HEATING = 0x38 + THERMOSTAT_MODE = 0x40 + THERMOSTAT_OPERATING_STATE = 0x42 + THERMOSTAT_SETPOINT = 0x43 + THERMOSTAT_FAN_MODE = 0x44 + THERMOSTAT_FAN_STATE = 0x45 + CLIMATE_CONTROL_SCHEDULE = 0x46 + THERMOSTAT_SETBACK = 0x47 + DOOR_LOCK_LOGGING = 0x4C + SCHEDULE_ENTRY_LOCK = 0x4E + BASIC_WINDOW_COVERING = 0x50 + MTP_WINDOW_COVERING = 0x51 + ASSOCIATION_GRP_INFO = 0x59 + DEVICE_RESET_LOCALLY = 0x5A + CENTRAL_SCENE = 0x5B + IP_ASSOCIATION = 0x5C + ANTITHEFT = 0x5D + ZWAVEPLUS_INFO = 0x5E + MULTI_CHANNEL_V2 = 0x60 + MULTI_INSTANCE = 0x60 + DOOR_LOCK = 0x62 + USER_CODE = 0x63 + BARRIER_OPERATOR = 0x66 + CONFIGURATION = 0x70 + CONFIGURATION_V2 = 0x70 + ALARM = 0x71 + MANUFACTURER_SPECIFIC = 0x72 + POWERLEVEL = 0x73 + PROTECTION = 0x75 + PROTECTION_V2 = 0x75 + LOCK = 0x76 + NODE_NAMING = 0x77 + FIRMWARE_UPDATE_MD = 0x7A + GROUPING_NAME = 0x7B + REMOTE_ASSOCIATION_ACTIVATE = 0x7C + REMOTE_ASSOCIATION = 0x7D + BATTERY = 0x80 + CLOCK = 0x81 + HAIL = 0x82 + WAKE_UP = 0x84 + WAKE_UP_V2 = 0x84 + ASSOCIATION = 0x85 + ASSOCIATION_V2 = 0x85 + VERSION = 0x86 + INDICATOR = 0x87 + PROPRIETARY = 0x88 + LANGUAGE = 0x89 + TIME = 0x8A + TIME_PARAMETERS = 0x8B + GEOGRAPHIC_LOCATION = 0x8C + COMPOSITE = 0x8D + MULTI_CHANNEL_ASSOCIATION_V2 = 0x8E + MULTI_INSTANCE_ASSOCIATION = 0x8E + MULTI_CMD = 0x8F + ENERGY_PRODUCTION = 0x90 + MANUFACTURER_PROPRIETARY = 0x91 + SCREEN_MD = 0x92 + SCREEN_MD_V2 = 0x92 + SCREEN_ATTRIBUTES = 0x93 + SCREEN_ATTRIBUTES_V2 = 0x93 + SIMPLE_AV_CONTROL = 0x94 + AV_CONTENT_DIRECTORY_MD = 0x95 + AV_RENDERER_STATUS = 0x96 + AV_CONTENT_SEARCH_MD = 0x97 + SECURITY = 0x98 + AV_TAGGING_MD = 0x99 + IP_CONFIGURATION = 0x9A + ASSOCIATION_COMMAND_CONFIGURATION = 0x9B + SENSOR_ALARM = 0x9C + SILENCE_ALARM = 0x9D + SENSOR_CONFIGURATION = 0x9E + MARK = 0xEF + NON_INTEROPERABLE = 0xF0 diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py b/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py index 8923fbecfd88a176f9559468e1a02a373f131e05..9b33f22d3f91e9130a187a64c920ed4006c9ea75 100644 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py @@ -1,9 +1,11 @@ # from xaal.lib import tools import asyncio -import pdb + +# import pdb import logging -from pprint import pprint + +# from pprint import pprint from zwave_js_server.client import Client as ZwaveClient @@ -12,6 +14,7 @@ from aiohttp.client import ClientSession from xaal.lib import AsyncEngine from xaal.schemas import devices +from .cmdclass import COMMAND_CLASS PACKAGE_NAME = 'xaal.zwavejs' @@ -20,7 +23,8 @@ logger = logging.getLogger(__name__) logging.getLogger("zwave_js_server").setLevel(logging.WARNING) -URL = "ws://10.77.3.143:3000" +# URL = "ws://10.77.3.143:3000" +URL = "ws://localhost:3000" class GW: @@ -45,7 +49,6 @@ class GW: async def run(self): await self.ready.wait() assert self.client.driver - # logger.warning(self.client.controller.nodes) logger.warning("ZwaveJS ready") nodes = self.client.driver.controller.nodes for node in nodes.values(): @@ -59,10 +62,16 @@ class GW: # pprint(node.data) def on_value_updated(self, event): - cmd_class = event["args"]["commandClass"] + cmd_class = int(event["args"]["commandClass"]) nodeId = event["nodeId"] value = event["value"] - logger.warning(f"{nodeId}.{value.endpoint} {cmd_class}={value.property_key_name}=>{event["args"]["newValue"]}") + prop = event["args"]["property"] + if prop in ["value", "currentValue", "targetValue"]: + prop = value.property_key_name + logger.warning(f"{nodeId}.{value.endpoint} {COMMAND_CLASS(cmd_class)}={prop}=>{event["args"]["newValue"]}") + # if cmd_class == 49 and nodeId == 4: + # pdb.set_trace() + # print(event)