]> git.basschouten.com Git - openhab-addons.git/blob
78bded02d8c7e0332879d11821885fa3a6afe4a6
[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.velux.internal.things;
14
15 import java.util.Map;
16 import java.util.function.Function;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21
22 /**
23  *
24  * The {@link VeluxKLFAPI} class defines common KLF200 API constants, which are
25  * used across the whole binding.
26  * <P>
27  * It provides the Enumeration of available API message identifiers as well as
28  * constants which describe the KLF200 API restrictions.
29  * <P>
30  * Classes/Enumeration available:
31  * <UL>
32  * <LI>Enumeration {@link Command} provides command name, coding and description.</LI>
33  * <LI>Class {@link CommandName} to handle symbolic API names.</LI>
34  * <LI>Class {@link CommandNumber} to handle API code.</LI>
35  * </UL>
36  * Constants available:
37  * <UL>
38  * <LI>{@link #KLF_SYSTEMTABLE_MAX} provides limits of the System table.</LI>
39  * </UL>
40  * <P>
41  *
42  * @author Guenther Schreiner - Initial contribution.
43  */
44 @NonNullByDefault
45 public class VeluxKLFAPI {
46
47     // Constants
48
49     /**
50      * System table index parameter - a number from 0 to 203.
51      *
52      * See <a href=
53      * "https://velcdn.azureedge.net/~/media/com/api/klf200/technical%20specification%20for%20klf%20200%20api.pdf#page=25">KLF200
54      * System table</a>
55      */
56     public static final int KLF_SYSTEMTABLE_MAX = 203;
57
58     // Type definitions
59
60     /**
61      * Handle symbolic names of the {@link VeluxKLFAPI}.
62      * <P>
63      * Methods available:
64      * <UL>
65      * <LI>Constructor {@link CommandName} by String.</LI>
66      * <LI>Method {@link toString} to return a String.</LI>
67      * </UL>
68      */
69     public static class CommandName {
70         private String name;
71
72         CommandName(String name) {
73             this.name = name;
74         }
75
76         @Override
77         public String toString() {
78             return name;
79         }
80     }
81
82     /**
83      * Handle API codings of the {@link VeluxKLFAPI}.
84      * <P>
85      * Methods available:
86      * <UL>
87      * <LI>CommandNumber {@link CommandName} by short.</LI>
88      * <LI>Method {@link toShort} to return a short.</LI>
89      * <LI>Method {@link toString} to return a well-formatted String.</LI>
90      * </UL>
91      */
92     public static class CommandNumber {
93         private short commandNumber;
94
95         public CommandNumber(short commandNumber) {
96             this.commandNumber = commandNumber;
97         }
98
99         public short toShort() {
100             return commandNumber;
101         }
102
103         @Override
104         public String toString() {
105             return "0x" + Integer.toHexString(Short.valueOf(commandNumber).intValue());
106         }
107     }
108
109     /**
110      * Enumeration of complete API as definition of a
111      * List of Gateway commands.
112      * <P>
113      * See <a href=
114      * "https://velcdn.azureedge.net/~/media/com/api/klf200/technical%20specification%20for%20klf%20200%20api.pdf#page=115">Appendix
115      * 3: List of Gateway commands</a>
116      * <P>
117      * Methods available:
118      * <UL>
119      * <LI>Constructor {@link Command} by String.</LI>
120      * <LI>Method {@link getCommand} to return a {@link CommandNumber}.</LI>
121      * <LI>Method {@link getDescription} to return a description as String.</LI>
122      * <LI>Method {@link get} to return a {@link Command} based on the given <B>int</B>.</LI>
123      * </UL>
124      */
125     public enum Command {
126         // Special item: unrecognized command
127         UNDEFTYPE((short) -1, "Unknown command."),
128         // Special item: Shutdown of the connection
129         GW_OPENHAB_CLOSE((short) -2, "openHAB connection shutdown command."),
130         // Special item: Empty Command (used to send nothing and process an incoming message only)
131         GW_OPENHAB_RECEIVEONLY((short) -3, "openHAB receive command."),
132         // Velux specific commands
133         GW_ERROR_NTF((short) 0x0000, "Provides information on what triggered the error."),
134         GW_REBOOT_REQ((short) 0x0001, "Request gateway to reboot."),
135         GW_REBOOT_CFM((short) 0x0002, "Acknowledge to GW_REBOOT_REQ command."),
136         GW_SET_FACTORY_DEFAULT_REQ((short) 0x0003,
137                 "Request gateway to clear system table, scene table and set Ethernet settings to factory default. Gateway will reboot."),
138         GW_SET_FACTORY_DEFAULT_CFM((short) 0x0004, "Acknowledge to GW_SET_FACTORY_DEFAULT_REQ command."),
139         GW_GET_VERSION_REQ((short) 0x0008, "Request version information."),
140         GW_GET_VERSION_CFM((short) 0x0009, "Acknowledge to GW_GET_VERSION_REQ command."),
141         GW_GET_PROTOCOL_VERSION_REQ((short) 0x000A, "Request KLF 200 API protocol version."),
142         GW_GET_PROTOCOL_VERSION_CFM((short) 0x000B, "Acknowledge to GW_GET_PROTOCOL_VERSION_REQ command."),
143         GW_GET_STATE_REQ((short) 0x000C, "Request the state of the gateway"),
144         GW_GET_STATE_CFM((short) 0x000D, "Acknowledge to GW_GET_STATE_REQ command."),
145
146         GW_LEAVE_LEARN_STATE_REQ((short) 0x000E, "Request gateway to leave learn state."),
147         GW_LEAVE_LEARN_STATE_CFM((short) 0x000F, "Acknowledge to GW_LEAVE_LEARN_STATE_REQ command."),
148         GW_GET_NETWORK_SETUP_REQ((short) 0x00E0, "Request network parameters."),
149         GW_GET_NETWORK_SETUP_CFM((short) 0x00E1, "Acknowledge to GW_GET_NETWORK_SETUP_REQ."),
150         GW_SET_NETWORK_SETUP_REQ((short) 0x00E2, "Set network parameters."),
151         GW_SET_NETWORK_SETUP_CFM((short) 0x00E3, "Acknowledge to GW_SET_NETWORK_SETUP_REQ."),
152
153         GW_CS_GET_SYSTEMTABLE_DATA_REQ((short) 0x0100, "Request a list of nodes in the gateways system table."),
154         GW_CS_GET_SYSTEMTABLE_DATA_CFM((short) 0x0101, "Acknowledge to GW_CS_GET_SYSTEMTABLE_DATA_REQ"),
155         GW_CS_GET_SYSTEMTABLE_DATA_NTF((short) 0x0102,
156                 "Acknowledge to GW_CS_GET_SYSTEM_TABLE_DATA_REQList of nodes in the gateways systemtable."),
157         GW_CS_DISCOVER_NODES_REQ((short) 0x0103, "Start CS  DiscoverNodes macro in KLF200."),
158         GW_CS_DISCOVER_NODES_CFM((short) 0x0104, "Acknowledge to GW_CS_DISCOVER_NODES_REQ command."),
159         GW_CS_DISCOVER_NODES_NTF((short) 0x0105, "Notification to GW_CS_DISCOVER_NODES_REQ command."),
160         GW_CS_REMOVE_NODES_REQ((short) 0x0106, "Remove one or more nodes  in the systemtable."),
161         GW_CS_REMOVE_NODES_CFM((short) 0x0107, "Acknowledge to GW_CS_REMOVE_NODES_REQ."),
162         GW_CS_VIRGIN_STATE_REQ((short) 0x0108, "Clear systemtable and delete system key."),
163         GW_CS_VIRGIN_STATE_CFM((short) 0x0109, "Acknowledge to GW_CS_VIRGIN_STATE_REQ."),
164         GW_CS_CONTROLLER_COPY_REQ((short) 0x010A,
165                 "Setup KLF200 to get or give a system to or from another io-homecontrol®  remote control. By a system means all nodes in the systemtable and the system key."),
166         GW_CS_CONTROLLER_COPY_CFM((short) 0x010B, "Acknowledge to GW_CS_CONTROLLER_COPY_REQ."),
167         GW_CS_CONTROLLER_COPY_NTF((short) 0x010C, "Notification to GW_CS_CONTROLLER_COPY_REQ."),
168         GW_CS_CONTROLLER_COPY_CANCEL_NTF((short) 0x010D, "Cancellation of system copy to other controllers."),
169         GW_CS_RECEIVE_KEY_REQ((short) 0x010E, "Receive system key from another controller."),
170         GW_CS_RECEIVE_KEY_CFM((short) 0x010F, "Acknowledge to GW_CS_RECEIVE_KEY_REQ."),
171         GW_CS_RECEIVE_KEY_NTF((short) 0x0110, "Notification to GW_CS_RECEIVE_KEY_REQ with status."),
172         GW_CS_PGC_JOB_NTF((short) 0x0111,
173                 "Information on Product Generic Configuration job initiated by  press on PGC button."),
174         GW_CS_SYSTEM_TABLE_UPDATE_NTF((short) 0x0112,
175                 "Broadcasted to all clients and gives information about added and removed actuator nodes in system table."),
176         GW_CS_GENERATE_NEW_KEY_REQ((short) 0x0113, "Generate new system key and update actuators in systemtable."),
177         GW_CS_GENERATE_NEW_KEY_CFM((short) 0x0114, "Acknowledge to GW_CS_GENERATE_NEW_KEY_REQ."),
178         GW_CS_GENERATE_NEW_KEY_NTF((short) 0x0115, "Acknowledge to GW_CS_GENERATE_NEW_KEY_REQ with status."),
179         GW_CS_REPAIR_KEY_REQ((short) 0x0116, "Update key in actuators holding an old  key."),
180         GW_CS_REPAIR_KEY_CFM((short) 0x0117, "Acknowledge to GW_CS_REPAIR_KEY_REQ."),
181         GW_CS_REPAIR_KEY_NTF((short) 0x0118, "Acknowledge to GW_CS_REPAIR_KEY_REQ with status."),
182         GW_CS_ACTIVATE_CONFIGURATION_MODE_REQ((short) 0x0119,
183                 "Request one or more actuator to open for configuration."),
184         GW_CS_ACTIVATE_CONFIGURATION_MODE_CFM((short) 0x011A, "Acknowledge to GW_CS_ACTIVATE_CONFIGURATION_MODE_REQ."),
185
186         GW_GET_NODE_INFORMATION_REQ((short) 0x0200, "Request extended information of one specific actuator node."),
187         GW_GET_NODE_INFORMATION_CFM((short) 0x0201, "Acknowledge to GW_GET_NODE_INFORMATION_REQ."),
188         GW_GET_NODE_INFORMATION_NTF((short) 0x0210, "Notification to GW_GET_NODE_INFORMATION_REQ."),
189         GW_GET_ALL_NODES_INFORMATION_REQ((short) 0x0202, "Request extended information of all nodes."),
190         GW_GET_ALL_NODES_INFORMATION_CFM((short) 0x0203, "Acknowledge to GW_GET_ALL_NODES_INFORMATION_REQ"),
191         GW_GET_ALL_NODES_INFORMATION_NTF((short) 0x0204,
192                 "Notification to GW_GET_ALL_NODES_INFORMATION_REQ. Holds node information"),
193         GW_GET_ALL_NODES_INFORMATION_FINISHED_NTF((short) 0x0205,
194                 "Notificatione to GW_GET_ALL_NODES_INFORMATION_REQ. No more nodes."),
195         GW_SET_NODE_VARIATION_REQ((short) 0x0206, "Set node variation."),
196         GW_SET_NODE_VARIATION_CFM((short) 0x0207, "Acknowledge to GW_SET_NODE_VARIATION_REQ."),
197         GW_SET_NODE_NAME_REQ((short) 0x0208, "Set node name."),
198         GW_SET_NODE_NAME_CFM((short) 0x0209, "Acknowledge to GW_SET_NODE_NAME_REQ."),
199         GW_SET_NODE_VELOCITY_REQ((short) 0x020A, "Set node velocity."),
200         GW_SET_NODE_VELOCITY_CFM((short) 0x020B, "Acknowledge to GW_SET_NODE_VELOCITY_REQ."),
201         GW_NODE_INFORMATION_CHANGED_NTF((short) 0x020C, "Notification that information has been updated."),
202         GW_NODE_STATE_POSITION_CHANGED_NTF((short) 0x0211, "Notification information has been updated."),
203         GW_SET_NODE_ORDER_AND_PLACEMENT_REQ((short) 0x020D, "Set search order and room placement."),
204         GW_SET_NODE_ORDER_AND_PLACEMENT_CFM((short) 0x020E, "Acknowledge to GW_SET_NODE_ORDER_AND_PLACEMENT_REQ."),
205
206         GW_GET_GROUP_INFORMATION_REQ((short) 0x0220, "Request information about  all defined groups."),
207         GW_GET_GROUP_INFORMATION_CFM((short) 0x0221, "Acknowledge to GW_GET_GROUP_INFORMATION_REQ."),
208         GW_GET_GROUP_INFORMATION_NTF((short) 0x0230, "Notification to GW_GET_GROUP_INFORMATION_REQ."),
209         GW_SET_GROUP_INFORMATION_REQ((short) 0x0222, "Change an existing group."),
210         GW_SET_GROUP_INFORMATION_CFM((short) 0x0223, "Acknowledge to GW_SET_GROUP_INFORMATION_REQ."),
211         GW_GROUP_INFORMATION_CHANGED_NTF((short) 0x0224,
212                 "Broadcast to all, about group information of a group has been changed."),
213         GW_DELETE_GROUP_REQ((short) 0x0225, "Delete a group."),
214         GW_DELETE_GROUP_CFM((short) 0x0226, "Acknowledge to GW_DELETE_GROUP_INFORMATION_REQ."),
215         GW_NEW_GROUP_REQ((short) 0x0227, "Request new group to be created."),
216         GW_NEW_GROUP_CFM((short) 0x0228, ""),
217         GW_GET_ALL_GROUPS_INFORMATION_REQ((short) 0x0229, "Request information about  all defined groups."),
218         GW_GET_ALL_GROUPS_INFORMATION_CFM((short) 0x022A, "Acknowledge to GW_GET_ALL_GROUPS_INFORMATION_REQ."),
219         GW_GET_ALL_GROUPS_INFORMATION_NTF((short) 0x022B, "Notification to GW_GET_ALL_GROUPS_INFORMATION_REQ."),
220         GW_GET_ALL_GROUPS_INFORMATION_FINISHED_NTF((short) 0x022C,
221                 "Notification to GW_GET_ALL_GROUPS_INFORMATION_REQ."),
222         GW_GROUP_DELETED_NTF((short) 0x022D,
223                 "GW_GROUP_DELETED_NTF is broadcasted to all, when a group has been removed."),
224         GW_HOUSE_STATUS_MONITOR_ENABLE_REQ((short) 0x0240, "Enable house status monitor."),
225         GW_HOUSE_STATUS_MONITOR_ENABLE_CFM((short) 0x0241, "Acknowledge to GW_HOUSE_STATUS_MONITOR_ENABLE_REQ."),
226         GW_HOUSE_STATUS_MONITOR_DISABLE_REQ((short) 0x0242, "Disable house status monitor."),
227         GW_HOUSE_STATUS_MONITOR_DISABLE_CFM((short) 0x0243, "Acknowledge to GW_HOUSE_STATUS_MONITOR_DISABLE_REQ."),
228
229         GW_COMMAND_SEND_REQ((short) 0x0300, "Send activating command direct to one or more io-homecontrol®  nodes."),
230         GW_COMMAND_SEND_CFM((short) 0x0301, "Acknowledge to GW_COMMAND_SEND_REQ."),
231         GW_COMMAND_RUN_STATUS_NTF((short) 0x0302, "Notification gives run status for io-homecontrol®  node."),
232         GW_COMMAND_REMAINING_TIME_NTF((short) 0x0303,
233                 "Notification gives remaining time before io-homecontrol®  node enter target position."),
234         GW_SESSION_FINISHED_NTF((short) 0x0304,
235                 "Notification command send, Status request, Wink, Mode or Stop session is finished."),
236         GW_STATUS_REQUEST_REQ((short) 0x0305, "Get status request from one or more io-homecontrol®  nodes."),
237         GW_STATUS_REQUEST_CFM((short) 0x0306, "Acknowledge to GW_STATUS_REQUEST_REQ."),
238         GW_STATUS_REQUEST_NTF((short) 0x0307,
239                 "Notification to GW_STATUS_REQUEST_REQ. Status request from one or more io-homecontrol®  nodes."),
240         GW_WINK_SEND_REQ((short) 0x0308, "Request from one or more io-homecontrol®  nodes to Wink."),
241         GW_WINK_SEND_CFM((short) 0x0309, "Acknowledge to GW_WINK_SEND_REQ"),
242         GW_WINK_SEND_NTF((short) 0x030A, "Notification status info for performed wink request."),
243
244         GW_SET_LIMITATION_REQ((short) 0x0310, "Set a parameter limitation in an actuator."),
245         GW_SET_LIMITATION_CFM((short) 0x0311, "Acknowledge to GW_SET_LIMITATION_REQ."),
246         GW_GET_LIMITATION_STATUS_REQ((short) 0x0312, "Get parameter limitation in an actuator."),
247         GW_GET_LIMITATION_STATUS_CFM((short) 0x0313, "Acknowledge to GW_GET_LIMITATION_STATUS_REQ."),
248         GW_LIMITATION_STATUS_NTF((short) 0x0314, "Notification hold information about limitation."),
249         GW_MODE_SEND_REQ((short) 0x0320, "Send Activate Mode to one or more io-homecontrol®  nodes."),
250         GW_MODE_SEND_CFM((short) 0x0321, "Acknowledge to GW_MODE_SEND_REQ"),
251         GW_MODE_SEND_NTF((short) 0x0322, "Notification with Mode activation info."),
252
253         GW_INITIALIZE_SCENE_REQ((short) 0x0400, "Prepare gateway to record a scene."),
254         GW_INITIALIZE_SCENE_CFM((short) 0x0401, "Acknowledge to GW_INITIALIZE_SCENE_REQ."),
255         GW_INITIALIZE_SCENE_NTF((short) 0x0402, "Notification to GW_INITIALIZE_SCENE_REQ."),
256         GW_INITIALIZE_SCENE_CANCEL_REQ((short) 0x0403, "Cancel record scene process."),
257         GW_INITIALIZE_SCENE_CANCEL_CFM((short) 0x0404, "Acknowledge to GW_INITIALIZE_SCENE_CANCEL_REQ command."),
258         GW_RECORD_SCENE_REQ((short) 0x0405, "Store actuator positions changes since GW_INITIALIZE_SCENE, as a scene."),
259         GW_RECORD_SCENE_CFM((short) 0x0406, "Acknowledge to GW_RECORD_SCENE_REQ."),
260         GW_RECORD_SCENE_NTF((short) 0x0407, "Notification to GW_RECORD_SCENE_REQ."),
261         GW_DELETE_SCENE_REQ((short) 0x0408, "Delete a recorded scene."),
262         GW_DELETE_SCENE_CFM((short) 0x0409, "Acknowledge to GW_DELETE_SCENE_REQ."),
263         GW_RENAME_SCENE_REQ((short) 0x040A, "Request a scene to be renamed."),
264         GW_RENAME_SCENE_CFM((short) 0x040B, "Acknowledge to GW_RENAME_SCENE_REQ."),
265         GW_GET_SCENE_LIST_REQ((short) 0x040C, "Request a list of scenes."),
266         GW_GET_SCENE_LIST_CFM((short) 0x040D, "Acknowledge to GW_GET_SCENE_LIST."),
267         GW_GET_SCENE_LIST_NTF((short) 0x040E, "Notification to GW_GET_SCENE_LIST."),
268         GW_GET_SCENE_INFOAMATION_REQ((short) 0x040F, "Request extended information for one given scene."),
269         GW_GET_SCENE_INFOAMATION_CFM((short) 0x0410, "Acknowledge to GW_GET_SCENE_INFOAMATION_REQ."),
270         GW_GET_SCENE_INFOAMATION_NTF((short) 0x0411, "Notification to GW_GET_SCENE_INFOAMATION_REQ."),
271         GW_ACTIVATE_SCENE_REQ((short) 0x0412, "Request gateway to enter a scene."),
272         GW_ACTIVATE_SCENE_CFM((short) 0x0413, "Acknowledge to GW_ACTIVATE_SCENE_REQ."),
273         GW_STOP_SCENE_REQ((short) 0x0415, "Request  all nodes  in a given scene to stop at their current position."),
274         GW_STOP_SCENE_CFM((short) 0x0416, "Acknowledge to GW_STOP_SCENE_REQ."),
275         GW_SCENE_INFORMATION_CHANGED_NTF((short) 0x0419, "Notification a scene has either been changed or removed."),
276
277         GW_ACTIVATE_PRODUCTGROUP_REQ((short) 0x0447, "Activate a product  group in a given direction."),
278         GW_ACTIVATE_PRODUCTGROUP_CFM((short) 0x0448, "Acknowledge to GW_ACTIVATE_PRODUCTGROUP_REQ."),
279         GW_ACTIVATE_PRODUCTGROUP_NTF((short) 0x0449, "Notification to GW_ACTIVATE_PRODUCTGROUP_REQ."),
280
281         GW_GET_CONTACT_INPUT_LINK_LIST_REQ((short) 0x0460,
282                 "Get list of assignments to all Contact Input to scene  or product  group."),
283         GW_GET_CONTACT_INPUT_LINK_LIST_CFM((short) 0x0461, "Acknowledge to GW_GET_CONTACT_INPUT_LINK_LIST_REQ."),
284         GW_SET_CONTACT_INPUT_LINK_REQ((short) 0x0462, "Set a link from a Contact Input to a scene  or product  group."),
285         GW_SET_CONTACT_INPUT_LINK_CFM((short) 0x0463, "Acknowledge to GW_SET_CONTACT_INPUT_LINK_REQ."),
286         GW_REMOVE_CONTACT_INPUT_LINK_REQ((short) 0x0464, "Remove a link from a Contact Input to a scene."),
287         GW_REMOVE_CONTACT_INPUT_LINK_CFM((short) 0x0465, "Acknowledge to GW_REMOVE_CONTACT_INPUT_LINK_REQ."),
288
289         GW_GET_ACTIVATION_LOG_HEADER_REQ((short) 0x0500, "Request header from activation log."),
290         GW_GET_ACTIVATION_LOG_HEADER_CFM((short) 0x0501, "Confirm header from activation log."),
291         GW_CLEAR_ACTIVATION_LOG_REQ((short) 0x0502, "Request clear all data  in activation log."),
292         GW_CLEAR_ACTIVATION_LOG_CFM((short) 0x0503, "Confirm clear all data  in activation log."),
293         GW_GET_ACTIVATION_LOG_LINE_REQ((short) 0x0504, "Request line from activation log."),
294         GW_GET_ACTIVATION_LOG_LINE_CFM((short) 0x0505, "Acknowledge to confirm line from activation log."),
295         GW_ACTIVATION_LOG_UPDATED_NTF((short) 0x0506, "Notification to confirm line from activation log."),
296         GW_GET_MULTIPLE_ACTIVATION_LOG_LINES_REQ((short) 0x0507, "Request lines from activation log."),
297         GW_GET_MULTIPLE_ACTIVATION_LOG_LINES_NTF((short) 0x0508, "Notification error log  data from activation log."),
298         GW_GET_MULTIPLE_ACTIVATION_LOG_LINES_CFM((short) 0x0509, "Acknowledge to confirm lines from activation log."),
299
300         GW_SET_UTC_REQ((short) 0x2000, "Request to set UTC time."),
301         GW_SET_UTC_CFM((short) 0x2001, "Acknowledge to GW_SET_UTC_REQ."),
302         GW_RTC_SET_TIME_ZONE_REQ((short) 0x2002, "Set time zone and daylight savings rules."),
303         GW_RTC_SET_TIME_ZONE_CFM((short) 0x2003, "Acknowledge to GW_RTC_SET_TIME_ZONE_REQ."),
304         GW_GET_LOCAL_TIME_REQ((short) 0x2004,
305                 "Request  the local time based on current time zone and daylight savings rules."),
306         GW_GET_LOCAL_TIME_CFM((short) 0x2005, "Acknowledge to GW_RTC_SET_TIME_ZONE_REQ."),
307         GW_PASSWORD_ENTER_REQ((short) 0x3000, "Enter password to authenticate request"),
308         GW_PASSWORD_ENTER_CFM((short) 0x3001, "Acknowledge to GW_PASSWORD_ENTER_REQ"),
309         GW_PASSWORD_CHANGE_REQ((short) 0x3002, "Request password change."),
310         GW_PASSWORD_CHANGE_CFM((short) 0x3003, "Acknowledge to GW_PASSWORD_CHANGE_REQ."),
311         GW_PASSWORD_CHANGE_NTF((short) 0x3004,
312                 "Notification to GW_PASSWORD_CHANGE_REQ. Broadcasted to all connected clients."),
313
314         ;
315
316         // Class internal
317
318         private CommandNumber command;
319         private String description;
320
321         // Reverse-lookup map for getting a Command from a TypeId
322         private static final Map<Short, Command> LOOKUPTYPEID2ENUM = Stream.of(Command.values())
323                 .collect(Collectors.toMap(Command::getShort, Function.identity()));
324
325         // Constructor
326
327         private Command(short typeId, String description) {
328             this.command = new CommandNumber(typeId);
329             this.description = description;
330         }
331
332         // Class access methods
333
334         public CommandNumber getCommand() {
335             return command;
336         }
337
338         public short getShort() {
339             return command.toShort();
340         }
341
342         public String getDescription() {
343             return description;
344         }
345
346         public static Command get(short thisTypeId) {
347             return LOOKUPTYPEID2ENUM.getOrDefault(thisTypeId, Command.UNDEFTYPE);
348         }
349     }
350 }