Tado items keep changing back to the previous value

I’ve install the 2.5.0 version of the tabo binding in openhab2.
Reading and persisting tado item values works like a breeze, not problem.
I have defined the tado things and items in text files.

Problem: when I change an item state, it is reset to its previous value after some time. Below is a typical example in the Karaf interface, the same happens when I try to write a rule.
It looks like the changes are not writting back all the way to the tado server and get updated back from the server to openhab at the next polling cycle.
Anyone can help ?

223 │ Active │ 80 │ 2.5.0.201903171839 │ Tado Binding
openhab> bundle:restart 223
openhab> smarthome:update badkamer_tado_opmode “MANUAL”
Update has been sent successfully.
openhab> smarthome:status badkamer_tado_opmode
SCHEDULE
openhab> smarthome:update badkamer_tado_opmode “MANUAL”
Update has been sent successfully.
openhab> smarthome:status badkamer_tado_opmode
MANUAL
openhab> smarthome:status badkamer_tado_opmode
SCHEDULE
openhab>

Another example

openhab> smarthome:update badkamer_tado_target_raw 23.0
Update has been sent successfully.
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
23.0
openhab> smarthome:status badkamer_tado_target_raw
21.0

Here is (part of) my things file

Bridge tado:home:AnneFrank6 [ username=““, password=”” ]{
zone badkamer [id=1]
zone bureau [id=2]
zone living [id=4]
}

Here are some item definitions

Number badkamer_tado_temp_raw “Temperatuur [%.1f °C]” <temperature> (gTemperatuur) { channel=“tado:zone:AnneFrank6:badkamer:currentTemperature” }
Number badkamer_tado_vocht “Vochtigheid [%d %%Rh]” { channel=“tado:zone:AnneFrank6:badkamer:humidity” }
Number badkamer_tado_power (gTemperatuur) { channel=“tado:zone:AnneFrank6:badkamer:heatingPower” }
Number badkamer_tado_target_raw (gTemperatuur) { channel=“tado:zone:AnneFrank6:badkamer:targetTemperature” }
String badkamer_tado_opmode { channel=“tado:zone:AnneFrank6:badkamer:operationMode” }
Number badkamer_tado_timerDuration { channel=“tado:zone:AnneFrank6:badkamer:timerDuration”

When you post and update to an Item, it only changes the Item’s state within openHAB. To cause that new state to be sent to the device, you need to use a command.

What is happening here is you are updating the state of the Item within openHAB. Then the binding polls the device and restores the state of the Item to the state of the device.

tl;dr - use command not update.

@rlkoshak, thanks for your help, your suggestion did the trick for that one rule, however, it broke another rule. It’s some problem with QuantityTypes which I can’t solve even after hours of searching through the documentation

The rule that is now working

rule “Update tado badkamer”
when
Item badkamerOpwarming changed
then
if (badkamerOpwarming.state == ON){
logInfo(“Badkamer”, “Badkamerverwarming AAN”)
badkamer_tado_target_raw.sendCommand(20.0|°C)
badkamer_tado_opmode.sendCommand(“TIMER”)
badkamer_tado_timerDuration.sendCommand(20)
}
else{
logInfo(“Badkamer”, “Badkamerverwarming UIT”)
badkamer_tado_opmode.send(“SCHEDULE”)
}
end

The rule that broker is this one (I tried solving the QuantityType issue without success)

var QuantityType<Number> offset = 2.0|°C
var QuantityType<Number> target
rule “Compenseert voor de temperatuur offset op de temperatuur meting in de badkamer door Tado”
when
Item badkamer_tado_target_raw changed
then
logInfo(“Badkamer”, ">>> Badkamer TADO temp RAW changed to " + badkamer_tado_target_raw.state)
logInfo(“Badkamer”, ">>> offset " + offset)
target = badkamer_tado_target_raw.state as QuantityType<Number> + offset
logInfo(“Badkamer”, ">>> Calculated target temperature is " + target )
postUpdate(badkamer_tado_target, target)
end

The error message is

21:46:16.449 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Compenseert voor de temperatuur offset op de temperatuur meting in de badkamer door Tado’: Could not cast 25.0 to org.eclipse.smarthome.core.library.types.QuantityType; line 11, column 14, length 54

Please use How to use code fences instead of quotes for code and logs.

I don’t do much with quantity types so I can’t say I know what the error means. But just from reading it it looks like you have something that is 25 and not 25|°C. Is your badkamer_tado_target_raw Item defined as a Number:Temperature?

@rlkoshak
OK, sorry for that
Yes, they are defined as Number:Termperature

Number:Temperature  badkamer_tado_temp_raw  "Temperatuur [%.1f °C]" <temperature> (gTemperatuur) { channel="tado:zone:AnneFrank6:badkamer:currentTemperature" }
Number:Temperature  badkamer_tado_temp     "Temperatuur [%.1f °C]" <temperature> (gTemperatuur) 

@rlkoshak
Do you know of any decent explanation about adding QuantityType<Temperature> values ? Or do you know anyone who’s knowledgeable in the field of calculating with temperatures ?

Not really. I pretty much only know what’s in the docs. I have to look it up every time it comes up to even remember the QuantityType part.

But I think the big clue in that error is you have a value in that Rule that is not a QuantityType, and is just a plain old Number.

@rlkoshak
Thanks for your input so far, I’ll investigate further and when I can nail it down, I’ll document it here, it may help others.

By the way, is there a typeof operatore in the rules scripting language ? That would be really help during debugging.

instanceof

example

if(MyNumber.state instanceof Number)

@rlkoshak
I meant an operator that prints the type of a variable like typeof myVariable. I have a c# background, it exists there and it’s a very handy operator.

OK, found the solution,
Define the items as Number, NOT as Number.Temperature and cast everything in the rue to Number.

// sets the counter to the value of a received command
rule "Compenseert voor de temperatuur offset op tado"
when
    Item badkamer_tado_target_raw changed 
then
    var rawTemp = badkamer_tado_temp_raw.state as Number
    var offset = 3.0 as Number
    badkamer_tado_temp.postUpdate(rawTemp + offset) 
    var rawTarget = badkamer_tado_target_raw.state as Number
    badkamer_tado_target.postUpdate(rawTarget + offset) 
    logInfo("Badkamer", "Badkamer temperatures offset was as SUCCES !!!!")
end  
MyObject.class.getCanonicalName

But this only tells you the bottom Class in the inheritance hierarchy.