Roller shutter rule: How can I implement something like a controll switch to activate or deactivate the rule?

  • Platform information: Raspberry Pi 3 B+
  • openHAB version: Openhabian / openHAB 2.4.0-1
  • Issue of the topic: please be detailed explaining your issue:


I´m a really beginner in Openhab2. I starting with small things like a rule for a roller shutter.
That worked fine. The roller shutter should close 30 min. after sun set and open in the morning at 6:45 from Mo-Fr. So far so good.
Now I want to implement something like a controll switch. Only if the control Switch is activ, the roller shutter should close and open.
After updateing the rule with the “val Rolladen_aktiv” the rule doesn´t work any longer?
I attached the hole rule, relevant items and the log file.
Can anybody help?

** Items configuration related to the issue**

Rollershutter Rolladen_Arbeitszimmer “Rolladen [%d %%]” {channel=“zwave:device:f658f7a4:node2:blinds_control”}

DateTime Sunset_Time “Sonnenuntergang [%1$tH:%1$tM]” { channel=“astro:sun:home:set#start” }

Switch Rolladen_OG_aktiv “Rolladensteuerung aktiv”

** Rules code related to the issue:**

val Rolladen_aktiv = if (Rolladen_OG_aktiv.state == On) 1 else 0

rule “Rolladen runter”
Channel ‘astro:sun:home:set#event’ triggered START
if (Rolladen_aktiv==1){ createTimer(now.plusMinutes(30)) [| Rolladen_Arbeitszimmer.sendCommand(70)]}

rule “Rolladen hoch”
Time cron “0 45 6 ? * MON-FRI *”
if (Rolladen_aktiv==1){Rolladen_Arbeitszimmer.sendCommand(UP)}

** If logs where generated please post these here using code fences**:

2019-04-25 22:18:28.592 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘Rolladen.rules’, using it anyway:

Cannot reference the field ‘Rolladen_OG_aktiv’ before it is defined

2019-04-25 22:18:28.607 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Rolladen.rules’

What’s that line about?

It would evaluate at the time the rules file is loaded, and be set at that value forever.

Presumably, you really want to check your state at the time that the rule runs.

rule “Rolladen runter”
    Channel ‘astro:sun:home:set#event’ triggered START
   if (Rolladen_OG_aktiv.state == ON) {
      // do stuff

Hi rossko57,

Thank you very much for your quick answer. You are right. I will try your comment.