Setpoint not sticking

Hi.
I’m controlling my room temperature with one Danfoss thermostat (014G0160) and on my three water radiators I have the Fibaro FGT-001 Thermostatic Valve. I control them via rules that set the setpoint according to the time of day - colder at night and on work hours and warmer when I’m home and awake.

rule "Work Morning 23.0" when Time cron "0 30 4 ? * MON-FRI *" then DanfossSetpoint.sendCommand(24.0) end

And I keep the temperature stable with this rule:

rule "Elutoa radikate lylitamine"


when
    Item DanfossSetpoint changed or
    Item DanfossTemperature changed
then
    var Number cur_temp = DanfossTemperature.state as Number
    var Number setpoint = DanfossSetpoint.state as Number
    val  Number hysteresis = 0.2

    if (cur_temp < (setpoint - hysteresis)) {
        if (Thermostat1_ThermostatMode.state !=1) {Thermostat1_ThermostatMode.sendCommand(1)}
           (Thermostat2_Mode.state != 1) {Thermostat2_Mode.sendCommand(1)}
           (KitchenThermostatMode.state != 1) {KitchenThermostatMode.sendCommand(1)}
    }
    else if(cur_temp > setpoint - hysteresis) {
        if (Thermostat1_ThermostatMode.state != 0) {Thermostat1_ThermostatMode.sendCommand(0)}
           (Thermostat2_Mode.state != 0) {Thermostat2_Mode.sendCommand(0)}
           (KitchenThermostatMode.state != 0) {KitchenThermostatMode.sendCommand(0)}
    }
end

This works perfectly. But when I set the temperature(setpoint) manually from the Dnafoss thermostat, it sets it for just a second and reverts it right away. Then when I check the setpoint on the thermostat,it still shows the one I set but when checking the Openhab conrol page, it shows the reverted setpoint.
Any ideas what’s going on?

Also, as you can see in the log, is that the change command is sent every time when thermostat temperature changes even 0.1 degrees, but it should be send only when it changes over or under the setpoint. Ideas on that aswell?

Best,
Marko

2020-03-11 08:29:41.721 [vent.ItemStateChangedEvent] - DanfossSetpoint changed from 18 ▒C to 24 ▒C
2020-03-11 08:29:41.744 [ome.event.ItemCommandEvent] - Item 'Thermostat1_ThermostatMode' received command 1
2020-03-11 08:29:41.747 [nt.ItemStatePredictedEvent] - Thermostat1_ThermostatMode predicted to become 1
2020-03-11 08:29:41.763 [ome.event.ItemCommandEvent] - Item 'Thermostat2_Mode' received command 1
2020-03-11 08:29:41.766 [vent.ItemStateChangedEvent] - Thermostat1_ThermostatMode changed from 0 to 1
2020-03-11 08:29:41.773 [nt.ItemStatePredictedEvent] - Thermostat2_Mode predicted to become 1
2020-03-11 08:29:41.779 [ome.event.ItemCommandEvent] - Item 'KitchenThermostatMode' received command 1
2020-03-11 08:29:41.784 [vent.ItemStateChangedEvent] - Thermostat2_Mode changed from 0 to 1
2020-03-11 08:29:41.788 [nt.ItemStatePredictedEvent] - KitchenThermostatMode predicted to become 1
2020-03-11 08:29:41.792 [vent.ItemStateChangedEvent] - KitchenThermostatMode changed from 0 to 1
2020-03-11 08:29:43.880 [vent.ItemStateChangedEvent] - DanfossSetpoint changed from 24 ▒C to 18 ▒C
2020-03-11 08:29:43.928 [ome.event.ItemCommandEvent] - Item 'Thermostat1_ThermostatMode' received command 0
2020-03-11 08:29:43.932 [ome.event.ItemCommandEvent] - Item 'Thermostat2_Mode' received command 0
2020-03-11 08:29:43.941 [ome.event.ItemCommandEvent] - Item 'KitchenThermostatMode' received command 0
2020-03-11 08:29:43.950 [nt.ItemStatePredictedEvent] - Thermostat1_ThermostatMode predicted to become 0
2020-03-11 08:29:43.954 [nt.ItemStatePredictedEvent] - Thermostat2_Mode predicted to become 0
2020-03-11 08:29:43.960 [nt.ItemStatePredictedEvent] - KitchenThermostatMode predicted to become 0
2020-03-11 08:29:43.965 [vent.ItemStateChangedEvent] - Thermostat1_ThermostatMode changed from 1 to 0
2020-03-11 08:29:43.968 [vent.ItemStateChangedEvent] - Thermostat2_Mode changed from 1 to 0
2020-03-11 08:29:43.971 [vent.ItemStateChangedEvent] - KitchenThermostatMode changed from 1 to 0
2020-03-11 08:29:44.458 [vent.ItemStateChangedEvent] - Thermostat2_Mode changed from 0 to 1
2020-03-11 08:29:45.315 [vent.ItemStateChangedEvent] - KitchenThermostatMode changed from 0 to 1
2020-03-11 08:29:52.203 [vent.ItemStateChangedEvent] - Thermostat2_Mode changed from 1 to 0
2020-03-11 08:29:54.291 [vent.ItemStateChangedEvent] - KitchenThermostatMode changed from 1 to 0
2020-03-11 08:31:17.209 [vent.ItemStateChangedEvent] - DanfossTemperature changed from 22.76 ▒C to 22.64 ▒C
2020-03-11 08:31:17.241 [me.event.ThingUpdatedEvent] - Thing 'zwave:device:6675270d:node11' has been updated.
2020-03-11 08:31:17.264 [ome.event.ItemCommandEvent] - Item 'Thermostat2_Mode' received command 0
2020-03-11 08:31:17.272 [nt.ItemStatePredictedEvent] - Thermostat2_Mode predicted to become 0
2020-03-11 08:31:17.287 [ome.event.ItemCommandEvent] - Item 'KitchenThermostatMode' received command 0
2020-03-11 08:31:17.294 [nt.ItemStatePredictedEvent] - KitchenThermostatMode predicted to become 0

That is unexpected. There are reports that it causes rules to restart. perhasp that’s where your unwanted setpoint command comes form.

In the thermostat rule,

might not be giving the results you expect. That’s a Number:Temperature type Item, isn’t it? The state is a QuantityType (with units) not a simple Number. Rule DSL is not a strongly typed language.

Use logInfo() in a rule to find out values
logInfo("my Investigation", "cur_temp " + cur_temp.toString)

Note that 27°C != 27 in this world.

Thanks for looking into it. I’m still a noob on “this world” so I don’t currently understand, where or how should I use the “logInfo”. Could You update my rule so it would be correct as You think it should be?

This is documented

Example (there are literally thousands in this forum)

rule "Elutoa radikate lylitamine"
when
    Item DanfossSetpoint changed or
    Item DanfossTemperature changed
then
    logInfo("test1", "starting rule")   // just a progress message
    var Number cur_temp = DanfossTemperature.state as Number
    logInfo(("test2", "cur_temp value " + cur_temp.toString)  // is that value what I expected
    var Number setpoint = DanfossSetpoint.state as Number
    logInfo(("test3", "setpoint value " + setpoint.toString)  // how about that value
    val  Number hysteresis = 0.2

You can remove or comment them out when you fix the problem.