mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Adjust command handling (#16159)
Signed-off-by: Christian Kittel <ckittel@gmx.de>
This commit is contained in:
parent
deb423e22c
commit
77e935aac1
@ -23,6 +23,8 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.measure.quantity.Temperature;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.ojelectronics.internal.config.OJElectronicsThermostatConfiguration;
|
||||
@ -195,8 +197,9 @@ public class ThermostatHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void updateManualSetpoint(Command command) {
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
getCurrentThermostat().manualModeSetpoint = (int) (quantityCommand.floatValue() * 100);
|
||||
QuantityType<?> harmonizedUnit = getHarmonizedQuantityType(command);
|
||||
if (harmonizedUnit != null) {
|
||||
getCurrentThermostat().manualModeSetpoint = (int) (harmonizedUnit.floatValue() * 100);
|
||||
} else {
|
||||
logger.warn("Unable to set value {}", command);
|
||||
}
|
||||
@ -235,8 +238,9 @@ public class ThermostatHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void updateComfortSetpoint(Command command) {
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
getCurrentThermostat().comfortSetpoint = (int) (quantityCommand.floatValue() * 100);
|
||||
QuantityType<?> harmonizedUnit = getHarmonizedQuantityType(command);
|
||||
if (harmonizedUnit != null) {
|
||||
getCurrentThermostat().comfortSetpoint = (int) (harmonizedUnit.floatValue() * 100);
|
||||
} else {
|
||||
logger.warn("Unable to set value {}", command);
|
||||
}
|
||||
@ -351,6 +355,17 @@ public class ThermostatHandler extends BaseThingHandler {
|
||||
return REGULATION_MODES.get(regulationMode);
|
||||
}
|
||||
|
||||
private @Nullable QuantityType<?> getHarmonizedQuantityType(Command command) {
|
||||
QuantityType<?> harmonizedUnit = null;
|
||||
|
||||
if (command instanceof QuantityType<?> quantityCommand) {
|
||||
harmonizedUnit = quantityCommand.toUnit(SIUnits.CELSIUS);
|
||||
} else if (command instanceof Number quantityCommand) {
|
||||
harmonizedUnit = new QuantityType<Temperature>(quantityCommand.floatValue(), SIUnits.CELSIUS);
|
||||
}
|
||||
return harmonizedUnit;
|
||||
}
|
||||
|
||||
private static Map<Integer, String> createRegulationMap() {
|
||||
HashMap<Integer, String> map = new HashMap<>();
|
||||
map.put(1, "auto");
|
||||
|
Loading…
Reference in New Issue
Block a user