I have a (dummy) Number item as following:
Number OpenWB_setSofortCurrent "A direct laden"
Which is controlled in my sitemap through a setpoint element:
Setpoint item=OpenWB_setSofortCurrent label="A direct laden [%d]" minValue=6 maxValue=16 step=1
The issue is that this item is a decimal type. The value is for example 16.0 (not 16)
I need to send this value to OpenWB (another software) and I do this using MQTT.
However, the value needs to be an integer, hence I have used following code in my rule to transform from decimal to integer
rule "OpenWB set minimum A for direct loading"
when
Item OpenWB_setSofortCurrent received command
then
val mqttActions = getActions("mqtt","mqtt:broker:myUnsecureBroker2")
var OpenWB_setSofortCurrentInt =(OpenWB_setSofortCurrent.state as Number).intValue
mqttActions.publishMQTT("openWB/config/set/sofort/lp/1/current",OpenWB_setSofortCurrentInt.toString, true)
end
This works… but not perfectly. Sometimes I change the setpoint from 6 to 7 and then it works. But then I go from 7 to 8, but the value stays at 7. If I then go to 8 again, then it works
My hypothesis is that this is due to the decimal type and the rounding to the integer, which for example rounds it down and hence the setpoint does not move higher.
Could someone help me out on this?