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.mqtt.homeassistant.internal.component;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import com.google.gson.annotations.SerializedName;
22 * The types of color modes a JSONSchemaLight can support.
24 * @author Cody Cutrer - Initial contribution
27 public enum LightColorMode {
28 @SerializedName("onoff")
30 @SerializedName("brightness")
31 COLOR_MODE_BRIGHTNESS,
32 @SerializedName("color_temp")
33 COLOR_MODE_COLOR_TEMP,
38 @SerializedName("rgb")
40 @SerializedName("rgbw")
42 @SerializedName("rgbww")
44 @SerializedName("white")
47 public static final List<LightColorMode> WITH_RGB = List.of(COLOR_MODE_RGB, COLOR_MODE_RGBW, COLOR_MODE_RGBWW);
48 public static final List<LightColorMode> WITH_COLOR_CHANNEL = List.of(COLOR_MODE_HS, COLOR_MODE_RGB,
49 COLOR_MODE_RGBW, COLOR_MODE_RGBWW, COLOR_MODE_XY);
52 * Determines if the list of supported modes includes any that should generate an openHAB Color channel
54 public static boolean hasColorChannel(List<LightColorMode> supportedColorModes) {
55 return WITH_COLOR_CHANNEL.stream().anyMatch(cm -> supportedColorModes.contains(cm));
59 * Determins if the list of supported modes includes any that have RGB components
61 public static boolean hasRGB(List<LightColorMode> supportedColorModes) {
62 return WITH_RGB.stream().anyMatch(cm -> supportedColorModes.contains(cm));