I’m having a contact on my window and would like to reduce the temperature to 5° once the window is opened. If the window is closed again it should set the temperature again to the value as it was before I opened the window.
My current code looks like this:
‘’‘rule "window"
when
Item Fenster_Wohnzimmer changed
then
if (Fenster_Wohnzimmer.state == OPEN){
Wozi_temp.postUpdate(Wozi_Haupt_Heizung_setpoint.state)
Wozi_Haupt_Heizung_setpoint.sendCommand(5)
if (Fenster_Wohnzimmer.state == CLOSED){
Wozi_Haupt_Heizung_setpoint.sendCommand(Wozi_temp.state)
}
}
end’’'
Wozi_Temp is a Number Item…
It works that the values are stored in the temp variable - but the setting back to the previous state is not triggering…
rule "window"
when
Item Fenster_Wohnzimmer changed
then
if (Fenster_Wohnzimmer.state == OPEN){
Wozi_temp.postUpdate(Wozi_Haupt_Heizung_setpoint.state)
Wozi_Haupt_Heizung_setpoint.sendCommand(5)
} // <-- This one is missing
if (Fenster_Wohnzimmer.state == CLOSED){
Wozi_Haupt_Heizung_setpoint.sendCommand(Wozi_temp.state)
}
end
In your rule you check for OPEN and within the OPEN-Path you check for CLOSED…(which never occurs…)
Andreas
Edit: Also you used the wrong “´” in your posting. You should use Shift-` on the german keyboard to get the code format the right way…
Is it only a problem of the Designer?
Or are you getting the error within the logs?
Is Wozi_temp.state uninitialized or undefined after a reboot?
Your rule initializes the value only if you opened the window once.
If it is running well after opening and closing the window, you have a problem with your initial state of the item.
if (Fenster_Wohnzimmer.state == CLOSED){
if (Wozi_temp.state == Undefined || Wozi_temp.state == Uninitialized)
{
Wozi_temp.state = 18.0
}
Wozi_Haupt_Heizung_setpoint.sendCommand(Wozi_temp.state)
}
or ignore the setting while the item is not initialized or defined:
if (Fenster_Wohnzimmer.state == CLOSED){
if (Wozi_temp.state != Undefined || Wozi_temp.state != Uninitialized)
{
Wozi_Haupt_Heizung_setpoint.sendCommand(Wozi_temp.state)
}
}
If this is not your Problem and your item contents a number, try to send the state explicitly as decimal number:
Wozi_Haupt_Heizung_setpoint.sendCommand(Wozi_temp.state as DecimalType)