diff --git a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAirconditionHandler.java b/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAirconditionHandler.java index c8cb9e69b7427..838c080d7deef 100644 --- a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAirconditionHandler.java +++ b/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/handler/PanasonicComfortCloudAirconditionHandler.java @@ -268,8 +268,12 @@ private void handleVerticalSwingCommand(ChannelUID channelUID, Command command, private void handleTargetTemperatureCommand(ChannelUID channelUID, Command command, Device device) { if (command instanceof RefreshType) { - updateState(channelUID, new QuantityType<>(device.getCurrentParameters().getTargetTemperature(), - device.getTemperatureUnit())); + if (device.getCurrentParameters().getTargetTemperature() == null) { + updateState(channelUID, UnDefType.UNDEF); + } else { + updateState(channelUID, new QuantityType<>(device.getCurrentParameters().getTargetTemperature(), + device.getTemperatureUnit())); + } } else { double targetTemperature = -1; if (command instanceof QuantityType) { @@ -361,7 +365,6 @@ private void handleCurrentOutdoorTemperatureCommand(ChannelUID channelUID, Comma private void sendParameters(ChannelUID channelUID, Device device, Parameters newParameters, State newStateIfSuccessfulUpdate) { try { - SetDevicePropertiesResponse rsp = accountHandler.getApiBridge().sendRequest( new SetDevicePropertiesRequest(device.getDeviceId(), newParameters.toParametersDTO(device)), SetDevicePropertiesResponse.class); diff --git a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/Parameters.java b/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/Parameters.java index fd34e44a3cfb8..1d847a7e9b58c 100644 --- a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/Parameters.java +++ b/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/Parameters.java @@ -12,7 +12,8 @@ */ package org.openhab.binding.panasoniccomfortcloud.internal.model; -import org.openhab.binding.panasoniccomfortcloud.internal.BindingConstants; +import java.util.Set; + import org.openhab.binding.panasoniccomfortcloud.internal.dto.ParametersDTO; /** @@ -20,7 +21,7 @@ */ public class Parameters { - public static final int INVALID_TEMPERATURE_READING = 126; + public static final Set INVALID_TEMPERATURE_READINGS = Set.of(126, -255); private Parameters shadowParameters = null; private AirSwingUpDown swingUpDown; private AirSwingSideways airSwingSideways; @@ -55,18 +56,14 @@ public Parameters(ParametersDTO dto, Device device) { nanoeMode = NanoeMode.parseValue(dto.nanoe); actualNanoeMode = NanoeMode.parseValue(dto.actualNanoe); masterSwitch = dto.operate != null && dto.operate != 0; - targetTemperature = dto.temperatureSet; - - if (BindingConstants.DEVICE_TYPE_WIFI_DONGLE.equals(device.getType())) { - // Bug in WiFi dongles reporting invalid temperature - if (dto.insideTemperature != INVALID_TEMPERATURE_READING) { - insideTemperature = dto.insideTemperature; - } - if (dto.outTemperature != INVALID_TEMPERATURE_READING) { - outsideTemperature = dto.outTemperature; - } - } else { + + if (!INVALID_TEMPERATURE_READINGS.contains(dto.temperatureSet)) { + targetTemperature = dto.temperatureSet; + } + if (!INVALID_TEMPERATURE_READINGS.contains(dto.insideTemperature)) { insideTemperature = dto.insideTemperature; + } + if (!INVALID_TEMPERATURE_READINGS.contains(dto.outTemperature)) { outsideTemperature = dto.outTemperature; } diff --git a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/TemperatureRange.java b/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/TemperatureRange.java deleted file mode 100644 index 72945e8b29739..0000000000000 --- a/bundles/org.openhab.binding.panasoniccomfortcloud/src/main/java/org/openhab/binding/panasoniccomfortcloud/internal/model/TemperatureRange.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2010-2022 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.panasoniccomfortcloud.internal.model; - -/** - * @author Arne Seime - Initial contribution - */ -public class TemperatureRange { - private static final int DEFAULT_MIN = 16; - private static final int DEFAULT_MAX = 30; - - private int min; - private int max; - - public TemperatureRange(int min, int max) { - this.min = set(min, DEFAULT_MIN); - this.max = set(max, DEFAULT_MAX); - } - - private int set(int value, int defaultValue) { - if (value == -1) { - return defaultValue; - } else { - return value; - } - } - - public boolean isValid(double targetValue) { - return targetValue >= min && targetValue <= max; - } - - @Override - public String toString() { - return "TemperatureRange{" + "min=" + min + ", max=" + max + '}'; - } -}