2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.milight.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.milight.internal.MilightThingState;
17 import org.openhab.binding.milight.internal.protocol.ProtocolConstants;
18 import org.openhab.binding.milight.internal.protocol.QueuedSend;
19 import org.openhab.core.thing.Thing;
22 * Implements the RGB white bulb. Both leds cannot be on at the same time, so no saturation or colour temperature
23 * control. It still allows more colours than the old v3 rgbw bulb (16320 (255*64) vs 4080 (255*16) colors).
25 * @author David Graeff - Initial contribution
28 public class MilightV6RGBWHandler extends AbstractLedV6Handler {
29 private static final int ADDR = 0x07;
31 public MilightV6RGBWHandler(Thing thing, QueuedSend sendQueue) {
32 super(thing, sendQueue, 20);
36 protected byte getAddr() {
41 public void setPower(boolean on, MilightThingState state) {
42 sendNonRepeatable(3, on ? 1 : 2);
46 public void whiteMode(MilightThingState state) {
47 sendRepeatableCat(ProtocolConstants.CAT_WHITEMODE, 3, 5);
51 public void nightMode(MilightThingState state) {
52 setPower(true, state);
53 sendRepeatableCat(ProtocolConstants.CAT_POWER_MODE, 3, 6);
57 public void setColorTemperature(int colorTemp, MilightThingState state) {
58 logger.info("Color temperature not supported by RGBW led!");
62 protected byte getBrCmd() {
67 public void setSaturation(int value, MilightThingState state) {
68 logger.info("Saturation not supported by RGBW led!");
72 public void setLedMode(int newmode, MilightThingState state) {
73 int mode = Math.max(Math.min(newmode, 9), 1);
74 sendRepeatableCat(ProtocolConstants.CAT_MODE_SET, 6, mode);
75 state.animationMode = mode;
79 public void changeSpeed(int relativeSpeed, MilightThingState state) {
80 sendNonRepeatable(4, relativeSpeed == 1 ? 3 : 4);