Skip to content

Commit 0ccaa33

Browse files
authored
[velbus] Add VMB4LEDPWM-20 OnOff command support (openhab#18287)
* [velbus] update README Signed-off-by: Daniel Rosengarten <[email protected]>
1 parent eb71708 commit 0ccaa33

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

bundles/org.openhab.binding.velbus/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,11 @@ Thing velbus:vmbdali:1:01 [VL1="CH1,CH2,CH3,CH4", VL2="A4,A5,A6"]
549549
| `clockAlarm` | `clockAlarm1WakeupHour`, `clockAlarm1WakeupMinute`, `clockAlarm1BedtimeHour`, `clockAlarm1BedtimeMinute`, `clockAlarm2WakeupHour`, `clockAlarm2WakeupMinute`, `clockAlarm2BedtimeHour`, `clockAlarm2BedtimeMinute` | Number | |
550550

551551
### Module `vmb4ledpwm-20`
552-
| Supported channels groups | Supported channels | Supported command types | Remarks |
553-
|---------------------------|------------------------|---------------------------------|-------------------|
554-
| `brightness` | `CH1` ... `CH4` | Percent | |
555-
| `fade-mode` | `CH1` ... `CH4` | Direct, Fade_Rate, Fade_Time | |
556-
| `scene` | `CH1` ... `CH4` | Number | Min = 1, Max = 15 |
552+
| Supported channels groups | Supported channels | Supported command types | Remarks |
553+
|---------------------------|------------------------|---------------------------------|----------------------------------------------------------------------------------------------------|
554+
| `brightness` | `CH1` ... `CH4` | OnOff, Percent | Sending an ON command will switch the dimmer to the value stored when last turning the dimmer off. |
555+
| `fade-mode` | `CH1` ... `CH4` | Direct, Fade_Rate, Fade_Time | |
556+
| `scene` | `CH1` ... `CH4` | Number | Min = 1, Max = 15 |
557557

558558
### Module `vmb8dc-20`
559559
| Supported channels groups | Supported channels | Supported command types | Remarks |

bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusNewDimmerHandler.java

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openhab.binding.velbus.internal.packets.VelbusSetDimPacket;
3030
import org.openhab.binding.velbus.internal.packets.VelbusSetScenePacket;
3131
import org.openhab.core.library.types.DecimalType;
32+
import org.openhab.core.library.types.OnOffType;
3233
import org.openhab.core.library.types.PercentType;
3334
import org.openhab.core.library.types.StringType;
3435
import org.openhab.core.thing.ChannelUID;
@@ -196,6 +197,16 @@ public void handleCommand(ChannelUID channelUID, Command command) {
196197
packet.setDim(colorChannel.getBrightnessVelbus());
197198
packet.setMode(fadeModeChannels[Byte.toUnsignedInt(channel) - 1]);
198199
velbusBridgeHandler.sendPacket(packet.getBytes());
200+
} else if (command instanceof OnOffType onOffCommand) {
201+
VelbusSetDimPacket packet = new VelbusSetDimPacket(address, channel);
202+
if (onOffCommand == OnOffType.ON) {
203+
packet.setLastUsedDim();
204+
} else {
205+
colorChannel.setBrightness(0);
206+
packet.setDim(colorChannel.getBrightnessVelbus());
207+
}
208+
packet.setMode(fadeModeChannels[Byte.toUnsignedInt(channel) - 1]);
209+
velbusBridgeHandler.sendPacket(packet.getBytes());
199210
} else {
200211
throw new UnsupportedOperationException(
201212
"The command '" + command + "' is not supported on channel '" + channelUID + "'.");

bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/packets/VelbusSetDimPacket.java

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public void setMode(byte mode) {
4040
data[3] = mode;
4141
}
4242

43+
public void setLastUsedDim() {
44+
data[0] = COMMAND_RESTORE_LAST_DIMVALUE;
45+
}
46+
4347
@Override
4448
protected byte[] getDataBytes() {
4549
return data;

0 commit comments

Comments
 (0)