Skip to content

Commit

Permalink
Hiding the -40 implementation detail from the user. This offset is no…
Browse files Browse the repository at this point in the history
…w an internal constant within the plugin and the external config parameter defaults to 0 degrees celsius. The sensor reading is then being added to the internal offset and the config parameter offset to come up with the final value.
  • Loading branch information
taboneclayton committed Sep 10, 2020
1 parent d880546 commit 234f746
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.gree.internal;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Set;

Expand Down Expand Up @@ -170,5 +169,5 @@ public class GreeBindingConstants {
*
* @See https://github.com/tomikaa87/gree-remote#getting-the-current-temperature-reading-from-the-internal-sensor for more details.
*/
public static final BigDecimal CURRENT_TEMP_OFFSET_DEFAULT = new BigDecimal(-40.0);
public static final double INTERNAL_TEMP_SENSOR_OFFSET = -40.0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*/
package org.openhab.binding.gree.internal;

import static org.openhab.binding.gree.internal.GreeBindingConstants.CURRENT_TEMP_OFFSET_DEFAULT;

import java.math.BigDecimal;
import org.eclipse.jdt.annotation.NonNullByDefault;

Expand All @@ -31,7 +29,7 @@ public class GreeConfiguration {
/**
* The currentTemperatureOffset is configureable in case the user wants to offset this temperature for calibration of the temperature sensor.
*/
public BigDecimal currentTemperatureOffset = CURRENT_TEMP_OFFSET_DEFAULT;
public BigDecimal currentTemperatureOffset = new BigDecimal(0.0);

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private void publishChannel(ChannelUID channelUID) {

private @Nullable State updateCurrentTemp() throws GreeException {
if (device.hasStatusValChanged(GREE_PROP_CURRENT_TEMP_SENSOR)) {
return new DecimalType(device.getIntStatusVal(GREE_PROP_CURRENT_TEMP_SENSOR) + config.currentTemperatureOffset.doubleValue());
return new DecimalType(device.getIntStatusVal(GREE_PROP_CURRENT_TEMP_SENSOR) + INTERNAL_TEMP_SENSOR_OFFSET + config.currentTemperatureOffset.doubleValue());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<advanced>true</advanced>
</parameter>
<parameter name="currentTemperatureOffset" type="decimal" step="0.5" required="true" unit="C">
<default>-40</default>
<default>0</default>
<unitLabel>Degrees Celsius</unitLabel>
<advanced>true</advanced>
</parameter>
Expand Down

0 comments on commit 234f746

Please sign in to comment.