2 * Copyright (c) 2010-2022 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);
242 public StateDecode decoder() {
247 public StateEncode encoder() {
252 enum AcGroup implements Epc {
254 AIR_FLOW_RATE(0xA0, new OptionCodec(
255 new Option("Auto", 0x41),
256 new Option("Rate 1", 0x31),
257 new Option("Rate 2", 0x32),
258 new Option("Rate 3", 0x33),
259 new Option("Rate 4", 0x34),
260 new Option("Rate 5", 0x35),
261 new Option("Rate 6", 0x36),
262 new Option("Rate 7", 0x37),
263 new Option("Rate 8", 0x38))),
265 AUTOMATIC_CONTROL_OF_AIR_FLOW_DIRECTION(0xA1, new OptionCodec(
266 new Option("Automatic", 0x41),
267 new Option("Non-automatic", 0x42),
268 new Option("Automatic (vertical)", 0x43),
269 new Option("Automatic (horizontal)", 0x44))),
271 AUTOMATIC_SWING_OF_AIR_FLOW(0xA3, new OptionCodec(
272 new Option("Not used", 0x31),
273 new Option("Used (vertical)", 0x41),
274 new Option("Used (horizontal)", 0x42),
275 new Option("Used (vertical and horizontal)", 0x43))),
277 AIR_FLOW_DIRECTION_VERTICAL(0xA4, new OptionCodec(
278 new Option("Uppermost", 0x41),
279 new Option("Lowermost", 0x42),
280 new Option("Mid-uppermost", 0x43),
281 new Option("Mid-lowermost", 0x44),
282 new Option("Central", 0x45))),
284 AIR_FLOW_DIRECTION_HORIZONTAL(0xA5, new OptionCodec(
285 new Option("XXXOO", 0x41),
286 new Option("OOXXX", 0x42),
287 new Option("XOOOX", 0x43),
288 new Option("OOXOO", 0x44),
289 new Option("XXXXO", 0x51),
290 new Option("XXXOX", 0x52),
291 new Option("XXOXX", 0x54),
292 new Option("XXOXO", 0x55),
293 new Option("XXOOX", 0x56),
294 new Option("XXOOO", 0x57),
295 new Option("XOXXX", 0x58),
296 new Option("XOXXO", 0x59),
297 new Option("XOXOX", 0x5A),
298 new Option("XOXOO", 0x5B),
299 new Option("XOOXX", 0x5C),
300 new Option("XOOXO", 0x5D),
301 new Option("XOOOO", 0x5F),
302 new Option("OXXXX", 0x60),
303 new Option("OXXXO", 0x61),
304 new Option("OXXOX", 0x62),
305 new Option("OXXOO", 0x63),
306 new Option("OXOXX", 0x64),
307 new Option("OXOXO", 0x65),
308 new Option("OXOOX", 0x66),
309 new Option("OXOOO", 0x67),
310 new Option("OOXXO", 0x69),
311 new Option("OOXOX", 0x6A),
312 new Option("OOOXX", 0x6C),
313 new Option("OOOXO", 0x6D),
314 new Option("OOOOX", 0x6E),
315 new Option("OOOOO", 0x6F))),
318 NON_PRIORITY_STATE(0xAB),
319 OPERATION_MODE(0xB0, new OptionCodec(
320 new Option("Automatic", 0x41),
321 new Option("Cooling", 0x42),
322 new Option("Heating", 0x43),
323 new Option("Dry", 0x44),
324 new Option("Fan", 0x45),
325 new Option("Other", 0x40))),
327 AUTOMATIC_TEMPERATURE_CONTROL(0xB1),
328 NORMAL_HIGH_SPEED_SILENT_OPERATION(0xB2),
329 SET_TEMPERATURE(0xB3, StateCodec.Temperature8bitCodec.INSTANCE),
330 SET_RELATIVE_HUMIDITY(0xB4),
331 SET_TEMPERATURE_COOLING_MODE(0xB5),
332 SET_TEMPERATURE_HEATING_MODE(0xB6),
333 SET_TEMPERATURE_DEHUMIDIFYING_MODE(0xB7),
334 RATED_POWER_CONSUMPTION(0xB8),
335 MEASURED_CURRENT_CONSUMPTION(0xB9),
336 MEASURED_ROOM_RELATIVE_HUMIDITY(0xBA),
337 MEASURED_ROOM_TEMPERATURE(0xBB, StateCodec.Temperature8bitCodec.INSTANCE, null),
338 SET_TEMPERATURE_USER_REMOTE_CONTROL(0xBC),
339 MEASURED_COOLED_AIR_TEMPERATURE(0xBD),
340 MEASURED_OUTDOOR_TEMPERATURE(0xBE, StateCodec.Temperature8bitCodec.INSTANCE, null),
341 RELATIVE_TEMPERATURE(0xBF);
344 public final int code;
347 public final StateDecode stateDecode;
350 public final StateEncode stateEncode;
353 this(code, null, null);
356 AcGroup(int code, @Nullable StateDecode stateDecode, @Nullable StateEncode stateEncode) {
358 this.stateDecode = stateDecode;
359 this.stateEncode = stateEncode;
362 AcGroup(int code, StateCodec stateCodec) {
363 this(code, stateCodec, stateCodec);
371 public StateDecode decoder() {
376 public StateEncode encoder() {
381 enum HomeAc implements Epc {
382 VENTILATION_FUNCTION(0xC0),
383 HUMIDIFIER_FUNCTION(0xC1),
384 VENTILATION_AIR_FLOW_RATE(0xC3);
386 public final int code;
397 enum Profile implements Epc {
398 OPERATING_STATUS(0x80, new OptionCodec(new Option("Booting", 0x30), new Option("Not booting", 0x31))),
399 VERSION_INFORMATION(0x82),
400 NODE_IDENTIFICATION_NUMBER(0x83),
403 public final int code;
406 public final StateDecode stateDecode;
408 public final StateEncode stateEncode;
411 this(code, null, null);
414 Profile(int code, @Nullable StateDecode stateDecode, @Nullable StateEncode stateEncode) {
416 this.stateDecode = stateDecode;
417 this.stateEncode = stateEncode;
420 Profile(int code, StateCodec stateCodec) {
421 this(code, stateCodec, stateCodec);
429 public StateDecode decoder() {
434 public StateEncode encoder() {
439 enum ProfileGroup implements Epc {
440 UNIQUE_IDENTIFIER_CODE(0xBF);
442 public final int code;
444 ProfileGroup(int code) {
453 enum NodeProfile implements Epc {
457 DEFAULT_ROUTER_DATA(0xE3),
458 ALL_ROUTER_DATA(0xE4),
459 LOCK_CONTROL_STATUS(0xEE),
460 LOCK_CONTROL_DATA(0xEF),
461 SECURE_COMMUNICATION_COMMON_KEY_SETUP_USER_KEY(0xC0),
462 SECURE_COMMUNICATION_COMMON_KEY_SETUP_SERVICE_PROVIDER_KEY(0xC1),
463 SECURE_COMMUNICATION_COMMON_KEY_SWITCHOVER_SETUP_USER_KEY(0xC2),
464 SECURE_COMMUNICATION_COMMON_KEY_SWITCHOVER_SETUP_SERVICE_PROVIDER_KEY(0xC3),
465 SECURE_COMMUNICATION_COMMON_KEY_SERIAL_KEY(0xC4),
466 SELF_NODE_INSTANCE_LIST_PAGE(0xD0),
467 SELF_NODE_CLASS_LIST(0xD2),
468 SELF_NODE_INSTANCE_COUNT(0xD3),
469 SELF_NODE_CLASS_COUNT(0xD4),
470 INSTANCE_CHANGE_CLASS_COUNT(0xD5),
471 SELF_NODE_INSTANCE_LIST_S(0xD6),
472 SELF_NODE_CLASS_LIST_S(0xD7),
473 RELATED_TO_OTHER_NODE_EA_LIST(0xD8),
474 RELATED_TO_OTHER_NODE_EA_COUNT(0xD9),
475 GROUP_BROADCAST_NUMBER(0xDA),;
477 public final int code;
479 NodeProfile(int code) {