Hi all,
I have upgraded from OpenHab 3.4.4 to OpenHab 4.0.1, one of the issue I experienced after upgrade is that when I adjust target temperature of my thermostats, it send command with input value divided by 10. I read the release notes of OH4 and saw there was introduction of Units Of Measurement, however I’m not sure my configuration needs any change. What I have observed so far:
- When I change target temp by the physical thermostat, OH get updated temp correctly.
- When I change target temp by OH, it sends temp/10 to the device. For example when I set target temp to 20, it sends 2 to the thermostat.
Below is my item configuration:
Number WavinOfficeTargetTemp "Office Target Temperature [%.1f °C]" <temperature> (gWavinOfficeThermostat) {homekit = "TargetTemperature" [minValue=15, maxValue=25, step=0.5], channel="zmartmodbus:jablotron_tp150:918a900e8b:chn9e2:ManualTemp"}
What I see in the events.log when I make a change in OH:
2023-08-13 08:26:22.318 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'WavinOfficeTargetTemp' received command 20.0
2023-08-13 08:26:22.343 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'WavinOfficeTargetTemp' predicted to become 20.0
2023-08-13 08:26:22.343 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'WavinOfficeTargetTemp' changed from 19.6 to 20.0
2023-08-13 08:26:34.422 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'WavinOfficeTargetTemp' changed from 20.0 to 2
What I see in events.log when I make a change from the thermostat:
2023-08-13 09:53:24.757 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'WavinOfficeTargetTemp' changed from 2 to 20
I’m not sure if this issue is due to the wrong item configuration or due to binding, but I did know that in the binding the conversion of numbers are made in a generic way that doesn’t seem to take care of measure of unit (I have to convert all primitive numbers to strings to make OH4 happy):
public static State fromModbusToState(ModbusThingChannel channel, Object payload) {
int index = channel.getIndex() * channel.getValueClass().size();
State state = UnDefType.UNDEF;
// logger.debug("{} {} {}", state, channel.getUID().getClass(),
// channel.getValueClass());
switch (channel.getValueClass()) {
case Bit:
state = (OnOffType) (((BitVector) payload).getBit(channel.getIndex()) == true ? OnOffType.ON
: OnOffType.OFF);
break;
case OnOff16:
state = (OnOffType) ((registerToShort((byte[]) payload, index) == 0) ? OnOffType.OFF : OnOffType.ON);
break;
case Int8:
state = new DecimalType(unsignedByteToInt(((byte[]) payload)[index])+"");
break;
case Uint16:
state = new DecimalType(registerToUnsignedShort((byte[]) payload, index)+"");
break;
case Int16:
state = new DecimalType(registerToShort((byte[]) payload, index)+"");
break;
case Uint32:
state = new DecimalType(registersToUnsignedInt((byte[]) payload, index)+"");
break;
case Int32:
state = new DecimalType(registersToInt((byte[]) payload, index)+"");
break;
case Float32:
state = new DecimalType(registersToFloat((byte[]) payload, index)+"");
break;
case Int32_swap:
state = new DecimalType(registersToIntSwap((byte[]) payload, index)+"");
break;
case Uint32_swap:
state = new DecimalType(registersToUnsignedIntSwap((byte[]) payload, index)+"");
break;
case Float32_swap:
state = new DecimalType(registersToFloatSwap((byte[]) payload, index)+"");
break;
case Jablotron_power16:
state = new DecimalType(((float) registerToUnsignedShort((byte[]) payload, index) * 24 / 0.54)+"");
break;
case Jablotron_power32:
state = new DecimalType(((float) registersToIntSwap((byte[]) payload, index) * 24 / 0.54)+"");
break;
case Jablotron_modeset:
state = new DecimalType(((int) ((BitVector) payload).getByte(index) & 0x0F)+"");
break;
case Custom8_4bit:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) & 0x0F)+"");
break;
case Custom8_5bit:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) & 0x1F)+"");
break;
case Custom8_6bit:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) & 0x3F)+"");
break;
case Custom8_7bit:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) & 0x7F)+"");
break;
case Jablotron_RSSI:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) * 0.5 - 74)+"");
break;
case Jablotron_battery:
state = new DecimalType((unsignedByteToInt(((byte[]) payload)[index]) * 10)+"");
However this section of code should only take care of conversion from the device to OpenHab state, so I’d be surprised that it causes the issue.
Any suggestion how to trouble shoot issue like this? Appreciate your input in advance!