blind_status.py: error due VMB2BL-VMB2BLE protocol differences
Closed this issue · 6 comments
Both VMB2BL (2-channel blind control module) and VMB2BLE (Two-channel blind control module with extended possibilities for din rail) send the blind status via the command_code 0xEC.
blind_status.py was written for VMB2BLE and works correctly for this module. For VMB2BL, blind status messages give an error due to differences in protocol:
VMB2BLE (protocol_info page 7/29)
Transmits the blind status:
DATABYTE1 = COMMAND_BLIND_STATUS (H’EC’)
DATABYTE2 = Blind channel
Contents - Relay number
B’00000001’ - Blind 1
B’00000010’ - Blind 2
VMB2BL (protocol_info page 5/13)
Transmits the blind status:
DATABYTE1 = COMMAND_BLIND_STATUS (H’EC’)
DATABYTE2 = Blind channel
Contents - Blind channel
B’00000011’ - Blind 1
B’00001100’ - Blind 2
According to the error message I got on my Raspberry Pi this gives a problem on line 74 of /python-velbus/velbus/messages/blind_status.py:
self.channel = self.byte_to_channel(data[0])
Error:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.5/dist-packages/serial/threaded/init.py", line 211, in run
self.protocol.connection_lost(error)
File "/usr/local/lib/python3.5/dist-packages/serial/threaded/init.py", line 34, in connection_lost
raise exc
File "/usr/local/lib/python3.5/dist-packages/serial/threaded/init.py", line 206, in run
self.protocol.data_received(data)
File "/home/pi/my_velbus/velbus/connections/init.py", line 16, in data_received
self.parser(data)
File "/home/pi/my_velbus/velbus/connections/init.py", line 87, in feed_parser
self.controller.feed_parser(data)
File "/home/pi/my_velbus/velbus/controller.py", line 44, in feed_parser
self.parser.feed(data)
File "/home/pi/my_velbus/velbus/parser.py", line 29, in feed
self.next_packet()
File "/home/pi/my_velbus/velbus/parser.py", line 80, in next_packet
message = self.parse(next_packet)
File "/home/pi/my_velbus/velbus/parser.py", line 127, in parse
message.populate(priority, address, rtr, data[5:-2])
File "/home/pi/my_velbus/velbus/messages/blind_status.py", line 75, in populate
self.channel = self.byte_to_channel(data[0])
File "/home/pi/my_velbus/velbus/message.py", line 132, in byte_to_channel
self.needs_one_channel(channels)
File "/home/pi/my_velbus/velbus/message.py", line 240, in needs_one_channel
self.parser_error("needs exactly one bit set in channel byte")
File "/home/pi/my_velbus/velbus/message.py", line 148, in parser_error
raise velbus.ParserError(self.class.name + " " + message)
velbus.parser.ParserError: BlindStatusMessage needs exactly one bit set in channel byte
Kind regards
NelisG
looking at this it seems you own the BL variant and pyvelbus expects a BLE variant
I have both VMB2BL and VMB2BLE modules. The error only occurs when VMB2BL is used (manually toggling the switches for example). For the VMB2BLE module everything works fine. It is indeed so that pyvelbus expects a message with command code 0xEC to be a status message from VMB2BLE. VMB2BL also uses this command code for the status message but sends a non-compatible Databyte2 .
i have a quick fix, but this will make sure that the VMBBL modules won't work.
The good fix will take some time
Could the problem be fixed by implementing the method byte_to_channel(byte) for the BlindStatusMessage class instead of using the byte_to_channel(byte) method of the parent (velbus.Message) class? Now velbus.Message.byte_to_channel(byte) returns 1 or 2 for Databyte2 of the VMB2BLE module (B’00000001' or B’00000010') as input. For Databyte2 ( B’00000011’ or B’00001100’) of the VMB2BL module this method will eventually execute self.needs_one_channel(channels) (velbus.Message line 149) with channels being equal to [1,2] or [3,4] depending on the bits in the input (00000011->[1,2] and 00001100->[3,4].)
As len(channels) != 1 this gives a parser error (velbus.Message line 270):
if len(channels) != 1 or ....
self.parser_error("needs exactly one bit set in channel byte")
So I was thinking that if the byte_to_channel(byte) method could be implemented for the BlindStatusMessage class to return (channel = ) 1 for inputs B’00000001' and B’00000011’ and return (channel = ) 2 for inputs B’00000010' and B’00001100’ that this would suffice.
Ok, I wil try to implement this for the VMB2BL module.