]> git.basschouten.com Git - openhab-addons.git/blob
7f57f2099838239fe021820695f0c18f2734874f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.milight.internal.handler;
14
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;
20
21 /**
22  * Implements the iBox led bulb. The bulb is integrated into the iBox and does not include a white channel, so no
23  * saturation or colour temperature available.
24  *
25  * @author David Graeff - Initial contribution
26  */
27 @NonNullByDefault
28 public class MilightV6RGBIBOXHandler extends AbstractLedV6Handler {
29     private static final byte ADDR = 0x00;
30
31     public MilightV6RGBIBOXHandler(Thing thing, QueuedSend sendQueue) {
32         super(thing, sendQueue, 0);
33     }
34
35     @Override
36     protected byte getAddr() {
37         return ADDR;
38     }
39
40     @Override
41     public void setPower(boolean on, MilightThingState state) {
42         sendNonRepeatable(3, on ? 3 : 4);
43     }
44
45     @Override
46     public void whiteMode(MilightThingState state) {
47         sendRepeatableCat(ProtocolConstants.CAT_WHITEMODE, 3, 5);
48     }
49
50     @Override
51     public void nightMode(MilightThingState state) {
52         logger.info("Night mode not supported by iBox led!");
53     }
54
55     @Override
56     public void setColorTemperature(int colorTemp, MilightThingState state) {
57         logger.info("Color temperature not supported by iBox led!");
58     }
59
60     @Override
61     public void changeColorTemperature(int colorTempRelative, MilightThingState state) {
62         logger.info("Color temperature not supported by iBox led!");
63     }
64
65     @Override
66     protected byte getBrCmd() {
67         return 2;
68     }
69
70     @Override
71     public void setSaturation(int value, MilightThingState state) {
72         logger.info("Saturation not supported by iBox led!");
73     }
74
75     @Override
76     public void setLedMode(int newmode, MilightThingState state) {
77         int mode = Math.max(Math.min(newmode, 9), 1);
78         sendRepeatableCat(ProtocolConstants.CAT_MODE_SET, 4, Math.max(Math.min(newmode, 9), 1));
79         state.animationMode = mode;
80     }
81
82     @Override
83     public void changeSpeed(int relativeSpeed, MilightThingState state) {
84         sendNonRepeatable(3, relativeSpeed > 1 ? 2 : 1);
85     }
86 }