With the recent chilly nights in the netherlands I found that my current version of the OTGW plugin doesn’t handle negative outside temperatures correctly
In the OT protocol outside temp is parameter 27, and the data type is f8.8.
f8.8 is defined in the protocol as:
signed fixed point value : 1 sign bit, 7 integer bit, 8 fractional bits (two’s compliment ie. the
LSB of the 16bit binary number represents 1/256th of a unit).
Two examples in the protocol:
A temperature of 21.5°C in f8.8 format is represented by the 2-byte value 1580 hex
(1580hex = 5504dec, dividing by 256 gives 21.5)
A temperature of -5.25°C in f8.8 format is represented by the 2-byte value FAC0 hex
(FAC0hex = - (10000hex-FACOhex) = - 0540hex = - 1344dec, dividing by 256 gives -5.25) .
The script OTGW-control of the OTGW plugin uses the follwing to parse the value:
message = (parseInt(opentherm_payload, 16) / 256).toFixed(2);
where opentherm_payload is the value received from the gateway.
It seams to work fine for temperatures of 0 and higher, but -1 degrees shows as 255, -2 as 254.
As i’m not familiar with Java (Script or JSON) I can’t figure out how to correct this.
Does anybody has some tips?