| | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) |
| | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) |
| Thermostat | | | | A thermostat requires at least one of TargetTemperature, CoolingThresholdTemperature, or HeatingThresholdTemperature must be provided. | | |
-| | CurrentHeatingCoolingMode | | Number, String | Current heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2) |
+| | CurrentHeatingCoolingMode | | Number, String, Switch | Current heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2) |
| | CurrentTemperature | | Number | Current temperature. | minValue (0), maxValue (100), step (0.1) | |
-| | TargetHeatingCoolingMode | | Number, String | Target heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2), AUTO (3) [*](#customizable-enum) |
+| | TargetHeatingCoolingMode | | Number, String, Switch | Target heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2), AUTO (3) [*](#customizable-enum) |
| | | TargetTemperature | Number | Target temperature. If CoolingThresholdTemperature and HeatingThresholdTemperature are also provided, this characteristic is used when the thermostat is in HEAT or COOL mode. In AUTO mode, this characteristic receives the average of the two thresholds. | minValue (10), maxValue (38), step (0.1) | |
| | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. If TargetTemperature is not provided, this characteristic will also be used in COOL mode. | minValue (10), maxValue (35), step (0.1) | |
| | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. If TargetTemperature is not provided, this characteristic will also be used in HEAT mode. | minValue (0), maxValue (25), step (0.1) | |
}
String onValue = switchType ? OnOffType.ON.toString() : OpenClosedType.OPEN.toString();
String offValue = switchType ? OnOffType.OFF.toString() : OpenClosedType.CLOSED.toString();
+ @Nullable
+ T offEnumValue = null, onEnumValue = null;
for (var k : klazz.getEnumConstants()) {
if (numberType) {
int code = k.getCode();
if ((switchType || contactType) && code == 0) {
map.put(k, inverted ? onValue : offValue);
+ offEnumValue = k;
} else if ((switchType || contactType) && code == 1) {
map.put(k, inverted ? offValue : onValue);
+ onEnumValue = k;
} else if (percentType && code == 0) {
map.put(k, "OFF");
} else if (percentType && code == 1) {
});
}
if (customEnumList != null && customEnumList.isEmpty()) {
- customEnumList.addAll(map.keySet());
+ if (switchType || contactType) {
+ // Switches and Contacts automatically filter the valid values to the first two
+ customEnumList.add(Objects.requireNonNull(offEnumValue));
+ customEnumList.add(Objects.requireNonNull(onEnumValue));
+ } else {
+ customEnumList.addAll(map.keySet());
+ }
}
LOGGER.debug("Created {} mapping for item {} ({}): {}", klazz.getSimpleName(), item.getName(),
item.getBaseItem().getClass().getSimpleName(), map);