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.echonetlite.internal;
15 import static org.openhab.binding.echonetlite.internal.EchonetLiteBindingConstants.ON_OFF_CODEC_30_31;
16 import static org.openhab.binding.echonetlite.internal.EchonetLiteBindingConstants.ON_OFF_CODEC_41_42;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.echonetlite.internal.StateCodec.Option;
21 import org.openhab.binding.echonetlite.internal.StateCodec.OptionCodec;
24 * @author Michael Barker - Initial contribution
27 public interface Epc {
33 default String type() {
37 default String channelId() {
38 return LangUtil.constantToVariable(name());
42 default StateDecode decoder() {
47 default StateEncode encoder() {
51 static Epc lookup(int groupCode, int classCode, int epcCode) {
52 return EpcLookupTable.INSTANCE.resolve(groupCode, classCode, epcCode);
55 // ECHONET SPECIFICATION
56 // APPENDIX Detailed Requirements for ECHONET Device objects
58 enum Device implements Epc {
60 OPERATION_STATUS(0x80, ON_OFF_CODEC_30_31),
62 INSTALLATION_LOCATION(0x81, new OptionCodec(
63 new Option("Not specified", 0b00000_000),
65 new Option("Living Room", 0b00001_000),
66 new Option("Living Room 1", 0b00001_001),
67 new Option("Living Room 2", 0b00001_010),
68 new Option("Living Room 3", 0b00001_011),
69 new Option("Living Room 4", 0b00001_100),
70 new Option("Living Room 5", 0b00001_101),
71 new Option("Living Room 6", 0b00001_110),
72 new Option("Living Room 7", 0b00001_111),
74 new Option("Dining Room", 0b00010_000),
75 new Option("Dining Room 1", 0b00010_001),
76 new Option("Dining Room 2", 0b00010_010),
77 new Option("Dining Room 3", 0b00010_011),
78 new Option("Dining Room 4", 0b00010_100),
79 new Option("Dining Room 5", 0b00010_101),
80 new Option("Dining Room 6", 0b00010_110),
81 new Option("Dining Room 7", 0b00010_111),
83 new Option("Kitchen", 0b00011_000),
84 new Option("Kitchen 1", 0b00011_001),
85 new Option("Kitchen 2", 0b00011_010),
86 new Option("Kitchen 3", 0b00011_011),
87 new Option("Kitchen 4", 0b00011_100),
88 new Option("Kitchen 5", 0b00011_101),
89 new Option("Kitchen 6", 0b00011_110),
90 new Option("Kitchen 7", 0b00011_111),
92 new Option("Lavatory", 0b00100_000),
93 new Option("Lavatory 1", 0b00100_001),
94 new Option("Lavatory 2", 0b00100_010),
95 new Option("Lavatory 3", 0b00100_011),
96 new Option("Lavatory 4", 0b00100_100),
97 new Option("Lavatory 5", 0b00100_101),
98 new Option("Lavatory 6", 0b00100_110),
99 new Option("Lavatory 7", 0b00100_111),
101 new Option("Washroom/changing room", 0b00101_000),
102 new Option("Washroom/changing room 1", 0b00101_001),
103 new Option("Washroom/changing room 2", 0b00101_010),
104 new Option("Washroom/changing room 3", 0b00101_011),
105 new Option("Washroom/changing room 4", 0b00101_100),
106 new Option("Washroom/changing room 5", 0b00101_101),
107 new Option("Washroom/changing room 6", 0b00101_110),
108 new Option("Washroom/changing room 7", 0b00101_111),
110 new Option("Passageway", 0b00111_000),
111 new Option("Passageway 1", 0b00111_001),
112 new Option("Passageway 2", 0b00111_010),
113 new Option("Passageway 3", 0b00111_011),
114 new Option("Passageway 4", 0b00111_100),
115 new Option("Passageway 5", 0b00111_101),
116 new Option("Passageway 6", 0b00111_110),
117 new Option("Passageway 7", 0b00111_111),
119 new Option("Room", 0b01000_000),
120 new Option("Room 1", 0b01000_001),
121 new Option("Room 2", 0b01000_010),
122 new Option("Room 3", 0b01000_011),
123 new Option("Room 4", 0b01000_100),
124 new Option("Room 5", 0b01000_101),
125 new Option("Room 6", 0b01000_110),
126 new Option("Room 7", 0b01000_111),
128 new Option("Stairway", 0b01001_000),
129 new Option("Stairway 1", 0b01001_001),
130 new Option("Stairway 2", 0b01001_010),
131 new Option("Stairway 3", 0b01001_011),
132 new Option("Stairway 4", 0b01001_100),
133 new Option("Stairway 5", 0b01001_101),
134 new Option("Stairway 6", 0b01001_110),
135 new Option("Stairway 7", 0b01001_111),
137 new Option("Front door", 0b01010_000),
138 new Option("Front door 1", 0b01010_001),
139 new Option("Front door 2", 0b01010_010),
140 new Option("Front door 3", 0b01010_011),
141 new Option("Front door 4", 0b01010_100),
142 new Option("Front door 5", 0b01010_101),
143 new Option("Front door 6", 0b01010_110),
144 new Option("Front door 7", 0b01010_111),
146 new Option("Storeroom", 0b01011_000),
147 new Option("Storeroom 1", 0b01011_001),
148 new Option("Storeroom 2", 0b01011_010),
149 new Option("Storeroom 3", 0b01011_011),
150 new Option("Storeroom 4", 0b01011_100),
151 new Option("Storeroom 5", 0b01011_101),
152 new Option("Storeroom 6", 0b01011_110),
153 new Option("Storeroom 7", 0b01011_111),
155 new Option("Garden/perimeter", 0b01100_000),
156 new Option("Garden/perimeter 1", 0b01100_001),
157 new Option("Garden/perimeter 2", 0b01100_010),
158 new Option("Garden/perimeter 3", 0b01100_011),
159 new Option("Garden/perimeter 4", 0b01100_100),
160 new Option("Garden/perimeter 5", 0b01100_101),
161 new Option("Garden/perimeter 6", 0b01100_110),
162 new Option("Garden/perimeter 7", 0b01100_111),
164 new Option("Garage", 0b01101_000),
165 new Option("Garage 1", 0b01101_001),
166 new Option("Garage 2", 0b01101_010),
167 new Option("Garage 3", 0b01101_011),
168 new Option("Garage 4", 0b01101_100),
169 new Option("Garage 5", 0b01101_101),
170 new Option("Garage 6", 0b01101_110),
171 new Option("Garage 7", 0b01101_111),
173 new Option("Veranda/balcony", 0b01110_000),
174 new Option("Veranda/balcony 1", 0b01110_001),
175 new Option("Veranda/balcony 2", 0b01110_010),
176 new Option("Veranda/balcony 3", 0b01110_011),
177 new Option("Veranda/balcony 4", 0b01110_100),
178 new Option("Veranda/balcony 5", 0b01110_101),
179 new Option("Veranda/balcony 6", 0b01110_110),
180 new Option("Veranda/balcony 7", 0b01110_111),
182 new Option("Others", 0b01111_000),
183 new Option("Others 1", 0b01111_001),
184 new Option("Others 2", 0b01111_010),
185 new Option("Others 3", 0b01111_011),
186 new Option("Others 4", 0b01111_100),
187 new Option("Others 5", 0b01111_101),
188 new Option("Others 6", 0b01111_110),
189 new Option("Others 7", 0b01111_111))),
191 STANDARD_VERSION_INFORMATION(0x82, StateCodec.StandardVersionInformationCodec.INSTANCE, null),
192 IDENTIFICATION_NUMBER(0x83, StateCodec.HexStringCodec.INSTANCE, null),
193 MEASURED_INSTANTANEOUS_POWER_CONSUMPTION(0x84),
194 MEASURED_CUMULATIVE_POWER_CONSUMPTION(0x85),
195 MANUFACTURER_FAULT_CODE(0x86, StateCodec.HexStringCodec.INSTANCE, null),
196 CURRENT_LIMIT_SETTING(0x87),
197 FAULT_STATUS(0x88, ON_OFF_CODEC_41_42, null),
198 FAULT_DESCRIPTION(0x89, StateCodec.HexStringCodec.INSTANCE, null),
199 MANUFACTURER_CODE(0x8A, StateCodec.HexStringCodec.INSTANCE, null),
200 BUSINESS_FACILITY_CODE(0x8B, StateCodec.HexStringCodec.INSTANCE, null),
202 PRODUCTION_NUMBER(0x8D),
203 PRODUCTION_DATE(0x8E),
204 POWER_SAVING_OPERATION_SETTING(0x8F, ON_OFF_CODEC_41_42),
205 REMOTE_CONTROL_SETTING(0x93),
206 CURRENT_TIME_SETTING(0x97),
207 CURRENT_DATE_SETTING(0x98),
208 POWER_LIMIT_SETTING(0x99),
209 CUMULATIVE_OPERATING_TIME(0x9A, StateCodec.OperatingTimeDecode.INSTANCE, null),
210 SETM_PROPERTY_MAP(0x9B),
211 GETM_PROPERTY_MAP(0x9C),
212 STATUS_CHANGE_ANNOUNCEMENT_PROPERTY_MAP(0x9D),
213 SET_PROPERTY_MAP(0x9E),
214 GET_PROPERTY_MAP(0x9F);
217 public final int code;
219 public final StateDecode stateDecode;
221 public final StateEncode stateEncode;
224 this(code, null, null);
227 Device(int code, @Nullable StateDecode stateDecode, @Nullable StateEncode stateEncode) {
229 this.stateDecode = stateDecode;
230 this.stateEncode = stateEncode;
233 Device(int code, StateCodec stateCodec) {
234 this(code, stateCodec, stateCodec);
244 public StateDecode decoder() {
250 public StateEncode encoder() {
255 enum AcGroup implements Epc {
257 AIR_FLOW_RATE(0xA0, new OptionCodec(
258 new Option("Auto", 0x41),
259 new Option("Rate 1", 0x31),
260 new Option("Rate 2", 0x32),
261 new Option("Rate 3", 0x33),
262 new Option("Rate 4", 0x34),
263 new Option("Rate 5", 0x35),
264 new Option("Rate 6", 0x36),
265 new Option("Rate 7", 0x37),
266 new Option("Rate 8", 0x38))),
268 AUTOMATIC_CONTROL_OF_AIR_FLOW_DIRECTION(0xA1, new OptionCodec(
269 new Option("Automatic", 0x41),
270 new Option("Non-automatic", 0x42),
271 new Option("Automatic (vertical)", 0x43),
272 new Option("Automatic (horizontal)", 0x44))),
274 AUTOMATIC_SWING_OF_AIR_FLOW(0xA3, new OptionCodec(
275 new Option("Not used", 0x31),
276 new Option("Used (vertical)", 0x41),
277 new Option("Used (horizontal)", 0x42),
278 new Option("Used (vertical and horizontal)", 0x43))),
280 AIR_FLOW_DIRECTION_VERTICAL(0xA4, new OptionCodec(
281 new Option("Uppermost", 0x41),
282 new Option("Lowermost", 0x42),
283 new Option("Mid-uppermost", 0x43),
284 new Option("Mid-lowermost", 0x44),
285 new Option("Central", 0x45))),
287 AIR_FLOW_DIRECTION_HORIZONTAL(0xA5, new OptionCodec(
288 new Option("XXXOO", 0x41),
289 new Option("OOXXX", 0x42),
290 new Option("XOOOX", 0x43),
291 new Option("OOXOO", 0x44),
292 new Option("XXXXO", 0x51),
293 new Option("XXXOX", 0x52),
294 new Option("XXOXX", 0x54),
295 new Option("XXOXO", 0x55),
296 new Option("XXOOX", 0x56),
297 new Option("XXOOO", 0x57),
298 new Option("XOXXX", 0x58),
299 new Option("XOXXO", 0x59),
300 new Option("XOXOX", 0x5A),
301 new Option("XOXOO", 0x5B),
302 new Option("XOOXX", 0x5C),
303 new Option("XOOXO", 0x5D),
304 new Option("XOOOO", 0x5F),
305 new Option("OXXXX", 0x60),
306 new Option("OXXXO", 0x61),
307 new Option("OXXOX", 0x62),
308 new Option("OXXOO", 0x63),
309 new Option("OXOXX", 0x64),
310 new Option("OXOXO", 0x65),
311 new Option("OXOOX", 0x66),
312 new Option("OXOOO", 0x67),
313 new Option("OOXXO", 0x69),
314 new Option("OOXOX", 0x6A),
315 new Option("OOOXX", 0x6C),
316 new Option("OOOXO", 0x6D),
317 new Option("OOOOX", 0x6E),
318 new Option("OOOOO", 0x6F))),
321 NON_PRIORITY_STATE(0xAB),
322 OPERATION_MODE(0xB0, new OptionCodec(
323 new Option("Automatic", 0x41),
324 new Option("Cooling", 0x42),
325 new Option("Heating", 0x43),
326 new Option("Dry", 0x44),
327 new Option("Fan", 0x45),
328 new Option("Other", 0x40))),
330 AUTOMATIC_TEMPERATURE_CONTROL(0xB1),
331 NORMAL_HIGH_SPEED_SILENT_OPERATION(0xB2),
332 SET_TEMPERATURE(0xB3, StateCodec.Temperature8bitCodec.INSTANCE),
333 SET_RELATIVE_HUMIDITY(0xB4),
334 SET_TEMPERATURE_COOLING_MODE(0xB5),
335 SET_TEMPERATURE_HEATING_MODE(0xB6),
336 SET_TEMPERATURE_DEHUMIDIFYING_MODE(0xB7),
337 RATED_POWER_CONSUMPTION(0xB8),
338 MEASURED_CURRENT_CONSUMPTION(0xB9),
339 MEASURED_ROOM_RELATIVE_HUMIDITY(0xBA),
340 MEASURED_ROOM_TEMPERATURE(0xBB, StateCodec.Temperature8bitCodec.INSTANCE, null),
341 SET_TEMPERATURE_USER_REMOTE_CONTROL(0xBC),
342 MEASURED_COOLED_AIR_TEMPERATURE(0xBD),
343 MEASURED_OUTDOOR_TEMPERATURE(0xBE, StateCodec.Temperature8bitCodec.INSTANCE, null),
344 RELATIVE_TEMPERATURE(0xBF);
347 public final int code;
350 public final StateDecode stateDecode;
353 public final StateEncode stateEncode;
356 this(code, null, null);
359 AcGroup(int code, @Nullable StateDecode stateDecode, @Nullable StateEncode stateEncode) {
361 this.stateDecode = stateDecode;
362 this.stateEncode = stateEncode;
365 AcGroup(int code, StateCodec stateCodec) {
366 this(code, stateCodec, stateCodec);
376 public StateDecode decoder() {
382 public StateEncode encoder() {
387 enum HomeAc implements Epc {
388 VENTILATION_FUNCTION(0xC0),
389 HUMIDIFIER_FUNCTION(0xC1),
390 VENTILATION_AIR_FLOW_RATE(0xC3);
392 public final int code;
404 enum Profile implements Epc {
405 OPERATING_STATUS(0x80, new OptionCodec(new Option("Booting", 0x30), new Option("Not booting", 0x31))),
406 VERSION_INFORMATION(0x82),
407 NODE_IDENTIFICATION_NUMBER(0x83),
410 public final int code;
413 public final StateDecode stateDecode;
415 public final StateEncode stateEncode;
418 this(code, null, null);
421 Profile(int code, @Nullable StateDecode stateDecode, @Nullable StateEncode stateEncode) {
423 this.stateDecode = stateDecode;
424 this.stateEncode = stateEncode;
427 Profile(int code, StateCodec stateCodec) {
428 this(code, stateCodec, stateCodec);
438 public StateDecode decoder() {
444 public StateEncode encoder() {
449 enum ProfileGroup implements Epc {
450 UNIQUE_IDENTIFIER_CODE(0xBF);
452 public final int code;
454 ProfileGroup(int code) {
464 enum NodeProfile implements Epc {
468 DEFAULT_ROUTER_DATA(0xE3),
469 ALL_ROUTER_DATA(0xE4),
470 LOCK_CONTROL_STATUS(0xEE),
471 LOCK_CONTROL_DATA(0xEF),
472 SECURE_COMMUNICATION_COMMON_KEY_SETUP_USER_KEY(0xC0),
473 SECURE_COMMUNICATION_COMMON_KEY_SETUP_SERVICE_PROVIDER_KEY(0xC1),
474 SECURE_COMMUNICATION_COMMON_KEY_SWITCHOVER_SETUP_USER_KEY(0xC2),
475 SECURE_COMMUNICATION_COMMON_KEY_SWITCHOVER_SETUP_SERVICE_PROVIDER_KEY(0xC3),
476 SECURE_COMMUNICATION_COMMON_KEY_SERIAL_KEY(0xC4),
477 SELF_NODE_INSTANCE_LIST_PAGE(0xD0),
478 SELF_NODE_CLASS_LIST(0xD2),
479 SELF_NODE_INSTANCE_COUNT(0xD3),
480 SELF_NODE_CLASS_COUNT(0xD4),
481 INSTANCE_CHANGE_CLASS_COUNT(0xD5),
482 SELF_NODE_INSTANCE_LIST_S(0xD6),
483 SELF_NODE_CLASS_LIST_S(0xD7),
484 RELATED_TO_OTHER_NODE_EA_LIST(0xD8),
485 RELATED_TO_OTHER_NODE_EA_COUNT(0xD9),
486 GROUP_BROADCAST_NUMBER(0xDA),;
488 public final int code;
490 NodeProfile(int code) {