From 480883a5f09ca11fe8e2e157fea372b7a0759097 Mon Sep 17 00:00:00 2001 From: jkerdreux-imt <jerome.kerdreux@imt-atlantique.fr> Date: Sun, 16 Feb 2025 12:27:58 +0100 Subject: [PATCH] Switch zwavejs command class module --- .../ZwaveJS/xaal/zwavejs/cmdclass.py | 104 ------------------ .../protocols/ZwaveJS/xaal/zwavejs/devices.py | 14 +-- devices/protocols/ZwaveJS/xaal/zwavejs/gw.py | 18 +-- 3 files changed, 13 insertions(+), 123 deletions(-) delete mode 100644 devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py b/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py deleted file mode 100644 index 967ba08a..00000000 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/cmdclass.py +++ /dev/null @@ -1,104 +0,0 @@ -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/devices.py b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py index 4864a1f7..e830a8c7 100644 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/devices.py @@ -1,15 +1,15 @@ -import pdb +# import pdb from logging import getLogger -from zwave_js_server.event import Event +# from zwave_js_server.event import Event from zwave_js_server.model.node import Node from zwave_js_server.model.value import Value +from zwave_js_server.const import CommandClass from xaal.schemas import devices from xaal.lib import tools, bindings, AsyncEngine, Device -from .cmdclass import COMMAND_CLASS from . import const logger = getLogger(__name__) @@ -27,7 +27,7 @@ def value_dump(value: Value): print(f"[{value}] {'0x%x'%value.command_class} {value.endpoint} {get_property_id(value)} => {value.value}") -def value_is_command_class(value: Value, command_class: COMMAND_CLASS): +def value_is_command_class(value: Value, command_class: CommandClass): return value.command_class == command_class.value @@ -52,13 +52,13 @@ def build_devices(node: Node, eng: AsyncEngine): value_dump(value) obj = None - if value_is_command_class(value, COMMAND_CLASS.SWITCH_BINARY): + if value_is_command_class(value, CommandClass.SWITCH_BINARY): obj = PowerRelay(node, value, base_addr) - if value_is_command_class(value, COMMAND_CLASS.SWITCH_MULTILEVEL): + if value_is_command_class(value, CommandClass.SWITCH_MULTILEVEL): obj = Lamp(node, value, base_addr) - if value_is_command_class(value, COMMAND_CLASS.METER): + if value_is_command_class(value, CommandClass.METER): obj = PowerMeter(node, value, base_addr) pass diff --git a/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py b/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py index 8149fbe6..e2e82a38 100644 --- a/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py +++ b/devices/protocols/ZwaveJS/xaal/zwavejs/gw.py @@ -1,23 +1,17 @@ # from xaal.lib import tools import asyncio - -import pdb import logging -from pprint import pprint - - -from zwave_js_server.client import Client as ZwaveClient from aiohttp.client import ClientSession +from zwave_js_server.client import Client as ZwaveClient from xaal.lib import AsyncEngine from xaal.schemas import devices from .cmdclass import COMMAND_CLASS -from .devices import build_devices from .const import EVT_VALUE_UPDATED - +from .devices import build_devices PACKAGE_NAME = 'xaal.zwavejs' @@ -26,8 +20,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 @@ -59,8 +53,8 @@ class GW: for node in nodes.values(): if node.ready: build_devices(node, self.engine) - # if DEBUG: - # node.on(EVT_VALUE_UPDATED, self.dump_event) + if DEBUG: + node.on(EVT_VALUE_UPDATED, self.dump_event) def dump_event(self, event): cmd_class = int(event["args"]["commandClass"]) -- GitLab