Skip to content

Commit

Permalink
Fix Temp sensor to show correct temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
pbogut committed Dec 29, 2020
1 parent 1555670 commit 3ecf280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private void publishChannelIfLinked(ChannelUID channelUID) {
} else if (CHANNEL_TEMP_SENSOR.equals(channelID)) {
stateValue = thisDevice.GetIntStatusValIfChanged("TemSen");
if (stateValue != null) {
state = new DecimalType(stateValue);
state = new DecimalType(thisDevice.GetDeviceTempSen());
}
} else if (CHANNEL_SWING_VERTICAL.equals(channelID)) {
stateValue = thisDevice.GetIntStatusValIfChanged("SwUpDn");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
*/

public class EWPEDevice {
private final static Integer ROOM_TEMP_OFFSET = 40;
private final static Charset UTF8_CHARSET = Charset.forName("UTF-8");
private final static HashMap<String, HashMap<String,Integer>> tempRanges = createTempRangeMap();
private Boolean mIsBound = false;
Expand Down Expand Up @@ -398,7 +399,17 @@ public Integer GetDeviceTempSet() {
}

public Integer GetDeviceTempSen() {
return GetIntStatusVal("TemSen");
// TemSen has 40 offset to avoid having negative values
Integer curVal = GetIntStatusVal("TemSen") - ROOM_TEMP_OFFSET;
Integer outVal = curVal;
Integer CorF = GetIntStatusVal("TemUn");
if (CorF == 1) { // If Fahrenheit,
// value argument is degrees F, convert Celsius to Fahrenheit,
// TemSen output from A/C is always in Celsius despite passing in 1
// to TemUn
outVal = Integer.valueOf((int)Math.round((curVal * 1.8) + 32.)); // Integer Truncated
}
return outVal;
}

public void SetDeviceAir(DatagramSocket clientSocket, Integer value) throws Exception {
Expand Down Expand Up @@ -493,7 +504,7 @@ public Integer GetIntStatusVal(String valueName) {
* "Tur": Turbo
* "StHt": 0,
* "TemUn": Temperature unit, 0 for Celsius, 1 for Fahrenheit
* "TemSen": Room Temperature
* "TemSen": Room Temperature with (+40 offset to avoid negative values)
* "HeatCoolType"
* "TemRec": (0 or 1), Send with SetTem, when TemUn==1, distinguishes between upper and lower integer Fahrenheit temp
* "SvSt": Power Saving
Expand Down

0 comments on commit 3ecf280

Please sign in to comment.