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.velux.internal.things;
16 import java.util.function.Function;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.velux.internal.VeluxBindingConstants;
24 * <B>Velux</B> product characteristics: Product Type.
27 * "https://velcdn.azureedge.net/~/media/com/api/klf200/technical%20specification%20for%20klf%20200%20api.pdf#page=112">KLF200
28 * List of actuator types and their use of Main Parameter and Functional Parameters</a>
30 * Methods in handle this type of information:
32 * <LI>{@link #get(int)} to convert a value into the VeluxProductType.</LI>
33 * <LI>{@link #toString(int)} to convert a value into the description of the VeluxProductType.</LI>
38 * @author Guenther Schreiner - initial contribution.
41 public enum VeluxProductType {
47 public enum ActuatorType {
48 UNDEFTYPE((short) 0xffff, VeluxBindingConstants.UNKNOWN, VeluxProductType.SWITCH),
49 BLIND_1_0((short) 0x0040, "Interior Venetian Blind", VeluxProductType.SLIDER_SHUTTER),
50 ROLLERSHUTTER_2_0((short) 0x0080, "Roller Shutter", VeluxProductType.SLIDER_SHUTTER),
51 ROLLERSHUTTER_2_1((short) 0x0081, "Roller Shutter", VeluxProductType.SLIDER_SHUTTER),
52 ROLLERSHUTTER_2_2((short) 0x0082, "Roller Shutter", VeluxProductType.SLIDER_SHUTTER),
53 AWNING_3_0((short) 0x00C0, "Vertical Exterior Awning", VeluxProductType.SLIDER_SHUTTER),
54 WINDOW_4_0((short) 0x0100, "Window opener", VeluxProductType.SLIDER_WINDOW),
55 WINDOW_4_1((short) 0x0101, "Window opener", VeluxProductType.SLIDER_WINDOW),
56 OPENER_5_0((short) 0x0140, "Garage door opener", VeluxProductType.SLIDER_SHUTTER),
57 OPENER_5_8((short) 0x017A, "Garage door opener", VeluxProductType.SLIDER_SHUTTER),
58 LIGHT_6_0((short) 0x0180, "Light", VeluxProductType.SLIDER_SHUTTER),
59 LIGHT_6_5((short) 0x01BA, "Light", VeluxProductType.SLIDER_SHUTTER),
60 OPENER_7_0((short) 0x01C0, "Gate opener", VeluxProductType.SLIDER_SHUTTER),
61 OPENER_7_5((short) 0x01FA, "Gate opener", VeluxProductType.SLIDER_SHUTTER),
62 LOCK_9_0((short) 0x0240, "Door lock", VeluxProductType.SLIDER_SHUTTER),
63 LOCK_9_1((short) 0x0241, "Window lock", VeluxProductType.SLIDER_SHUTTER),
64 BLIND_10((short) 0x0280, "Vertical Interior Blinds", VeluxProductType.SLIDER_SHUTTER),
65 SHUTTER_13((short) 0x0340, "Dual Roller Shutter", VeluxProductType.SLIDER_SHUTTER),
66 SWITCH_15((short) 0x03C0, "On/Off switch", VeluxProductType.SWITCH),
67 AWNING_16((short) 0x0400, "Horizontal awning", VeluxProductType.SLIDER_SHUTTER),
68 BLIND_17((short) 0x0440, "Exterior Venetian blind", VeluxProductType.SLIDER_SHUTTER),
69 BLIND_18((short) 0x0480, "Louver blind", VeluxProductType.SLIDER_SHUTTER),
70 TRACK_19((short) 0x04C0, "Curtain track", VeluxProductType.SLIDER_SHUTTER),
71 POINT_20((short) 0x0500, "Ventilation point", VeluxProductType.SLIDER_SHUTTER),
72 POINT_20_1((short) 0x0501, "Ventilation point", VeluxProductType.SLIDER_SHUTTER),
73 POINT_20_2((short) 0x0502, "Ventilation point", VeluxProductType.SLIDER_SHUTTER),
74 POINT_20_3((short) 0x0503, "Ventilation point", VeluxProductType.SLIDER_SHUTTER),
75 HEATING_21((short) 0x0540, "Exterior heating", VeluxProductType.SLIDER_SHUTTER),
76 HEATING_21_5((short) 0x57A, "Exterior heating", VeluxProductType.SLIDER_SHUTTER),
77 SHUTTER_24_0((short) 0x0600, "Swinging Shutters", VeluxProductType.SLIDER_SHUTTER),
78 SHUTTER_24_1((short) 0x0601, "Swinging Shutters", VeluxProductType.SLIDER_SHUTTER),;
82 private short nodeType;
83 private String description;
84 private VeluxProductType typeClass;
86 // Reverse-lookup map for getting an ActuatorType from a TypeId
87 private static final Map<Integer, ActuatorType> LOOKUPTYPEID2ENUM = Stream.of(ActuatorType.values())
88 .collect(Collectors.toMap(ActuatorType::getNodeType, Function.identity()));
92 private ActuatorType(short nodeType, String description, VeluxProductType typeClass) {
93 this.nodeType = nodeType;
94 this.description = description;
95 this.typeClass = typeClass;
98 // Class access methods
100 public int getNodeType() {
104 public String getDescription() {
108 public VeluxProductType getTypeClass() {
112 public static ActuatorType get(int nodeType) {
113 return LOOKUPTYPEID2ENUM.getOrDefault(nodeType, ActuatorType.UNDEFTYPE);
117 // Class access methods
119 public static VeluxProductType get(int nodeType) {
120 if (ActuatorType.get(nodeType) != ActuatorType.UNDEFTYPE) {
121 return ActuatorType.get(nodeType).typeClass;
123 return VeluxProductType.UNDEFTYPE;
127 public static String toString(int nodeType) {
128 return ActuatorType.get(nodeType).getDescription();