Define variables:

$temp-eco = 20
$temp-comf = 22
$temp-memory = 20
$temp-setpoint = 20

I also have a DummySwitch device for vacation mode named vacation-switch

Check if someone changed the thermostat to auto mode. This mode is also enabled if the cube is restarted:

when every 15 minutes and $heating-thermostat.mode = "auto" then set mode of heating-thermostat to "manu"

To avoid mistakes of cube connection errors or the “cube is busy” syndrom, check whether all commands were done successfully:

when [every 1 minute and [$temp-setpoint is not $heating-thermostat.temperatureSetpoint
    and $heating-thermostat.temperatureSetpoint > 4.5]] or $temp-setpoint changes
        then set temp of heating-thermostat to $temp-setpoint

Allow manual adjustment via the GUI or directly at the thermostat:

when $heating-thermostat.temperatureSetpoint changes
    and $heating-thermostat.temperatureSetpoint is not $temp-setpoint
    and $heating-thermostat.temperatureSetpoint > 4.5
        then $temp-setpoint = $heating-thermostat.temperatureSetpoint

Save energy if a window is opened and not closed again

when window is opened for 1 minute then $temp-setpoint = 5

Fall back to heating plan when window is closed:

when window is closed then $temp-setpoint = $temp-memory

Turn the heater up in the morning if someone is at home

when it is 6:00 and vacation-switch is off then set $temp-memory to $temp-comf
when it is 6:01 and window is closed and vacation-switch is off then $temp-setpoint = $temp-comf

Cool down the heater in the evening:

when it is 18:30 then set $temp-memory to $temp-eco
when it is 18:31 and window is closed then $temp-setpoint = $temp-eco