mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[velbus] Fix multiple channel status in one packet (#15272)
Fix bug : Manage more than one channel status in the packet. Signed-off-by: Daniel Rosengarten <github@praetorians.be>
This commit is contained in:
parent
2f5f37e136
commit
b650454d94
@ -141,28 +141,33 @@ public class VelbusSensorHandler extends VelbusThingHandler {
|
|||||||
byte command = packet[4];
|
byte command = packet[4];
|
||||||
|
|
||||||
if (command == COMMAND_PUSH_BUTTON_STATUS && packet.length >= 6) {
|
if (command == COMMAND_PUSH_BUTTON_STATUS && packet.length >= 6) {
|
||||||
byte channelJustPressed = packet[5];
|
|
||||||
if (channelJustPressed != 0) {
|
|
||||||
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
|
||||||
channelJustPressed);
|
|
||||||
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
|
||||||
CommonTriggerEvents.PRESSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte channelJustReleased = packet[6];
|
for (int channel = 0; channel < 8; channel++) {
|
||||||
if (channelJustReleased != 0) {
|
byte channelMask = (byte) Math.pow(2, channel);
|
||||||
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
|
||||||
channelJustReleased);
|
|
||||||
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
|
||||||
CommonTriggerEvents.RELEASED);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte channelLongPressed = packet[7];
|
byte channelJustPressed = (byte) (packet[5] & channelMask);
|
||||||
if (channelLongPressed != 0) {
|
if (channelJustPressed != 0) {
|
||||||
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
||||||
channelLongPressed);
|
channelJustPressed);
|
||||||
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
||||||
CommonTriggerEvents.LONG_PRESSED);
|
CommonTriggerEvents.PRESSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte channelJustReleased = (byte) (packet[6] & channelMask);
|
||||||
|
if (channelJustReleased != 0) {
|
||||||
|
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
||||||
|
channelJustReleased);
|
||||||
|
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
||||||
|
CommonTriggerEvents.RELEASED);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte channelLongPressed = (byte) (packet[7] & channelMask);
|
||||||
|
if (channelLongPressed != 0) {
|
||||||
|
VelbusChannelIdentifier velbusChannelIdentifier = new VelbusChannelIdentifier(address,
|
||||||
|
channelLongPressed);
|
||||||
|
triggerChannel("input#" + getModuleAddress().getChannelId(velbusChannelIdentifier),
|
||||||
|
CommonTriggerEvents.LONG_PRESSED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user