Skip to content

Commit

Permalink
Add new modules type, add new moduleType message format
Browse files Browse the repository at this point in the history
  • Loading branch information
cereal2nd committed Nov 29, 2023
1 parent 8aec1e3 commit dd344e3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 15 deletions.
15 changes: 15 additions & 0 deletions velbusaio/command_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}


Expand Down
2 changes: 1 addition & 1 deletion velbusaio/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
66 changes: 53 additions & 13 deletions velbusaio/messages/module_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion velbusaio/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd344e3

Please sign in to comment.