]> git.basschouten.com Git - openhab-addons.git/blob
ce67e39dd6e49239ef654dc7d9527c8ef39bebcf
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.boschshc.internal.services.hsbcoloractuator.dto;
14
15 import java.awt.Color;
16
17 import org.openhab.binding.boschshc.internal.services.dto.BoschSHCServiceState;
18 import org.openhab.core.library.types.HSBType;
19
20 /**
21  * State representing colors of light bulbs.
22  *
23  * @author David Pace - Initial contribution
24  *
25  */
26 public class HSBColorActuatorServiceState extends BoschSHCServiceState {
27
28     public HSBColorActuatorServiceState() {
29         super("colorState");
30     }
31
32     /**
33      * RGB value modeled as an sRGB integer value (bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).
34      * Alpha is set to the fixed value <code>255</code>.
35      */
36     public int rgb;
37
38     public String gamut;
39
40     public ColorTemperatureRange colorTemperatureRange;
41
42     /**
43      * Converts the combined {@link #rgb} value to an openHAB-compliant HSB state.
44      *
45      * @return color as {@link HSBType}
46      */
47     public HSBType toHSBType() {
48         Color color = new Color(rgb);
49         return HSBType.fromRGB(color.getRed(), color.getGreen(), color.getBlue());
50     }
51 }