From dd344e3f4014ceb754cfe3441d0d7d292d8600a5 Mon Sep 17 00:00:00 2001 From: Maikel Punie Date: Wed, 29 Nov 2023 09:18:52 +0100 Subject: [PATCH] Add new modules type, add new moduleType message format --- velbusaio/command_registry.py | 15 +++++++ velbusaio/messages/__init__.py | 2 +- velbusaio/messages/module_type.py | 66 +++++++++++++++++++++++++------ velbusaio/module.py | 2 +- 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/velbusaio/command_registry.py b/velbusaio/command_registry.py index 9a2b0ea..62a16c1 100644 --- a/velbusaio/command_registry.py +++ b/velbusaio/command_registry.py @@ -65,6 +65,21 @@ 0x43: "VMBIN", 0x44: "VMB4PB", 0x45: "VMBDALI", + 0x48: "VMB4RYLD-10", + 0x49: "VMB4RYNO-10", + 0x4A: "VMB2BLE-10", + 0x4C: "VMB6PB-20", + 0x4F: "VMBEL1-20", + 0x50: "VMBEL2-20", + 0x51: "VMBEL4-20", + 0x52: "VMBELO-20", + 0x53: "VMBGP1-20", + 0x54: "VMBGP2-20", + 0x55: "VMBGP4-20", + 0x56: "VMBGPO-20", + 0x5A: "VMBDALI-20", + 0x5C: "VMBEL4PIR-20", + 0x5F: "VMBGP4PIR-20", } diff --git a/velbusaio/messages/__init__.py b/velbusaio/messages/__init__.py index 8d0e7d0..ed2099d 100644 --- a/velbusaio/messages/__init__.py +++ b/velbusaio/messages/__init__.py @@ -54,7 +54,7 @@ from velbusaio.messages.module_status import ModuleStatusMessage, ModuleStatusMessage2 from velbusaio.messages.module_status_request import ModuleStatusRequestMessage from velbusaio.messages.module_subtype import ModuleSubTypeMessage -from velbusaio.messages.module_type import ModuleTypeMessage +from velbusaio.messages.module_type import ModuleTypeMessage, ModuleType2Message from velbusaio.messages.module_type_request import ModuleTypeRequestMessage from velbusaio.messages.push_button_status import PushButtonStatusMessage from velbusaio.messages.read_data_block_from_memory import ( diff --git a/velbusaio/messages/module_type.py b/velbusaio/messages/module_type.py index 6010ba5..049b5ed 100644 --- a/velbusaio/messages/module_type.py +++ b/velbusaio/messages/module_type.py @@ -66,18 +66,58 @@ def populate(self, priority, address, rtr, data): self.build_year = data[-2] self.build_week = data[-1] - def data_to_binary(self): + +@register( + COMMAND_CODE, + [ + "VMB4RYLD-10", + "VMB4RYNO-10", + "VMB2BLE-10", + "VMB6PB-20", + "VMBEL1-20", + "VMBEL2-20", + "VMBEL4-20", + "VMBELO-20", + "VMBGP1-20", + "VMBGP2-20", + "VMBGP4-20", + "VMBGPO-20", + "VMBGPO-20", + "VMBEL4PIR-20", + "VMBGP4PIR-20", + ], +) +class ModuleType2Message(Message): + def __init__(self, address=None): + Message.__init__(self) + self.module_type = 0x00 + self.led_on = [] + self.led_slow_blinking = [] + self.led_fast_blinking = [] + self.serial = 0 + self.memory_map_version = 0 + self.build_year = 0 + self.build_week = 0 + self.term = 0 + self.set_defaults(address) + + def module_name(self): """ - :return: bytes + :return: str + """ + return "Unknown" + + def populate(self, priority, address, rtr, data): + """ + :return: None """ - return bytes( - [ - COMMAND_CODE, - self.module_type, - self.channels_to_byte(self.led_on), - self.channels_to_byte(self.led_slow_blinking), - self.channels_to_byte(self.led_fast_blinking), - self.build_year, - self.build_week, - ] - ) + self.needs_low_priority(priority) + self.needs_no_rtr(rtr) + self.set_attributes(priority, address, rtr) + self.module_type = data[0] + if data[0] not in MODULES_WITHOUT_SERIAL: + (self.serial,) = struct.unpack(">L", bytes([0, 0, data[1], data[2]])) + self.memory_map_version = data[3] + self.build_year = data[-3] + self.build_week = data[-2] + self.term = data[-1] diff --git a/velbusaio/module.py b/velbusaio/module.py index 8a0ff6f..7e9a318 100644 --- a/velbusaio/module.py +++ b/velbusaio/module.py @@ -81,7 +81,7 @@ ) from velbusaio.messages.module_status_request import ModuleStatusRequestMessage from velbusaio.messages.module_subtype import ModuleSubTypeMessage -from velbusaio.messages.module_type import ModuleTypeMessage +from velbusaio.messages.module_type import ModuleTypeMessage, ModuleType2Message from velbusaio.messages.push_button_status import PushButtonStatusMessage from velbusaio.messages.read_data_from_memory import ReadDataFromMemoryMessage from velbusaio.messages.relay_status import RelayStatusMessage, RelayStatusMessage2