Rule with setpoint update does not work. Wrong variable is updated

Hi, what am i doing wrong here. I’m trying to replace fixed decimal numbers with a variable, so i can dynamically change the setpoint for several thermostats. But the problem is, that instead of updating the thermostate with the correct setpoint , instead the rule seems to read the current value of the thermostat, and update my new variable. Means, if i set Komfort_TEMP, after the rule has executed, Komfort_TEMP will be back on 22.

Any suggestions?

Existing rule that works.

rule "morning temp"
when
    Time cron "0 0 5 1/1 * ? *"
then
   {
   sendCommand(GF_Kitchen_setpoint, (22-0))     
   }   
end 

New rule that i cannot make work:

rule "morning temp"
when
    Time cron "0 0 5 1/1 * ? *"
then
   {
   sendCommand(GF_Kitchen_setpoint, (Komfort_TEMP.state as DecimalType - 0))     
   }   
end

Also tried this, but no better luck:

GF_Kitchen_setpoint.postupdate (Komfort_TEMP.state as DecimalType - 0))

items:

Number          Komfort_TEMP			"Komfort TEMP [%.1f C]"		<temperature>	(Radiators)
Number          GF_Kitchen_setpoint     "Køkken SP [%.1f C]" 		<temperature>	(GF_Kitchen, Radiators)	{ channel="zwave:device:a48f8251:node7:thermostat_setpoint_heating" }

//Ole

I’m guessing the ‘-0’ is what’s causing your issue. I would try as just the decimal type without it or as a concatenated string with it.

Thanks, that was a good guess and fixed my issue. Actually i tried that already and did not se it working, but was fooled by the fact that at every update of the rule file one of my other rules of initializing variables at system startup was triggered as well.
So now it (sort of) works doing the math with 2 variables instead:

rule "morning temp"
when
    Time cron "0 0 5 1/1 * ? *" or
	Item Vacation_away.state changed from ON to OFF or
	Item Vacation_home.state changed from OFF to ON or
	Item Komfort_TEMP received update
then
   if (Vacation_away.state == OFF) 
   {
   GF_Kitchen_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Kitchen_offset.state as DecimalType)
   GF_Living_east_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Living_east_offset)
   GF_Living_south_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Living_south_offset)
   GF_Corridor_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Corridor_offset)
   FF_Living_east_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - FF_Living_east_offset)
   }   
end

Unfortunately the rule is still not working…only the first command is executed correct. Any idea?

Event log:

2017-03-12 10:30:12.093 [ItemStateChangedEvent     ] - Komfort_TEMP changed from 23 to 23.5
2017-03-12 10:30:12.127 [ItemCommandEvent          ] - Item 'GF_Kitchen_setpoint' received command 23.5
2017-03-12 10:30:12.138 [ItemStateChangedEvent     ] - GF_Kitchen_setpoint changed from 23 to 23.5

Openhab.log:

2017-03-12 10:30:12.981 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'morning temp': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_minus(java.lang.Number,java.lang.Number) on instance: null
2017-03-12 10:30:13.129 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'morning temp': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_minus(java.lang.Number,java.lang.Number) on instance: null

//Ole

If i compare these two lines, the first one works and the second fails. I would suggest to try
GF_Living_east_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Living_east_offset.state as DecimalType)

note the addition of .state as DecimalType to GF_Living_east_offset
But this is a suggestion that is based on extrapolation only, I cannot find any info on how you defined GF_Living_east_offset, but as you seem to have GF_Kitchen_offset defines as an item I guessed that the other offsets are similarly defined; if so the above is likely to apply and similar changes would be necessary in the rest of your rule.

Offcause, thanks. I should have found that myself, sorry.

Now it works like a charm:

rule "morning temp"
when
    Time cron "0 0 5 1/1 * ? *" or
	Item Vacation_away.state changed from ON to OFF or
	Item Vacation_home.state changed from OFF to ON or
	Item Komfort_TEMP received update
then
   if (Vacation_away.state == OFF) 
   {
   GF_Kitchen_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Kitchen_offset.state as DecimalType)
   GF_Living_east_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Living_east_offset.state as DecimalType)
   GF_Living_south_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Living_south_offset.state as DecimalType)
   GF_Corridor_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - GF_Corridor_offset.state as DecimalType)
   FF_Living_east_setpoint.sendCommand(Komfort_TEMP.state as DecimalType - FF_Living_east_offset.state as DecimalType)
   }   
end

cheers, Ole