[SOLVED] A switch to turn on/ off rules

Hi, I’ve a simple question about switching a rule on and off:
l’m pretty sure that I need to create a switch item. My Question is how this Item can be created via paperUI…
Thanks in advance

Tom

You just makes a Switch Item and have the rules check the state of that Item before executing.

Create your things in the paperUI
Create your items in files

2 Likes

If you’ve activated “Simply Linking” then you can’t.

However, if Simple Linking is off, then just go to
Configuration / Items

And create an Item :smile:

I guess you’d be looking for a state checking rule like this as a way to enable or condition a rule ?

1 Like

If using scripted automation, you can enable or disable rules from PaperUI or from other rules. See https://openhab-scripters.github.io/openhab-helper-libraries/Guides/But%20How%20Do%20I.html#enable-or-disable-a-rule-by-uid.

Hi,
with a little help from this https://community.openhab.org/t/disabling-a-rule-with-a-switch/3869/8 i’ve done that:

  1. created a item

image

  1. modified my blinds/roller shutter rule:

rule “Rolladen hoch bei Sonnenaufgang”
when
Channel ‘astro:sun:local:civilDawn#event’ triggered START
then
if (Rolladensteuerung_AnAus_Switch.state == OFF) return false {
Rolladen_ALLE.sendCommand(1);
Rolladen_Hauswirtschaftsraum_BlindsControl.sendCommand(100)
}
End

  1. then I connected one of the “roller shutter”-things to the item (that’s the part I’m very unsure about) - just to make the switch visible (e.g. in the controls of the PaperUI).

I thought “great, there is a ‘switch’-channel in the FIBARO Roller Shutter - thing” to connect my item … but can it work that way …?

PS: @rlkoshak: Thanks für your input and link … but I’m afraid that is far beyond my skills :sob:

I don’t understand this at all.

Let’s point out that PaperUI is an adminstrative interface. It’s not for everyday use. It provides some controls for limited testing, but no customizing.

So if you are compromising your design to work with PaperUI you are probably doing it wrong.

Nope, you don’t connect the roller shutter channel to the newly created item Rolladensteuerung_AnAus_Switch.state. This item is a virtual item (for more info: Design Pattern: Unbound Item (aka Virtual Item)) to prevent the rule from running. It must not be connected to a channel.

your rule should be like:

rule “Rolladen hoch bei Sonnenaufgang”
when
    Channel ‘astro:sun:local:civilDawn#event’ triggered START
then
    if (Rolladensteuerung_AnAus_Switch.state == OFF) return;
    
    Rolladen_ALLE.sendCommand(1);
    Rolladen_Hauswirtschaftsraum_BlindsControl.sendCommand(100)
end

o.k. - but … ist there a way to get this (virtual) switch on the paperUI-Control …?

No and there is no reason to do that.
The Basic UI is meant for control. the Paper UI is just to administer openHAB. Some people use HABPanel instead of the Basic UI.

1 Like

Solution - Summary:
… help from this Disabling a rule with a switch i’ve done that:

  1. created a item - here via paperUI

image

  1. modified my blinds/roller shutter rule:

rule “Rolladen hoch bei Sonnenaufgang”
when
Channel ‘astro:sun:local:civilDawn#event’ triggered START
then
if (Rolladensteuerung_AnAus_Switch.state == OFF) return false {
Rolladen_ALLE.sendCommand(1);
Rolladen_Hauswirtschaftsraum_BlindsControl.sendCommand(100)
}
End

  1. Use the ITEM “Rolladensteuerung_AnAus_Switch” in a HABpanel - configuration, because there’s no way to bring this ITEM in the paperUI-Controll-Section (sorry for the screenshot in german language:

    grafik
1 Like

Hi

One tiny detail.

Are you ‘persisting’ the state of your new Switch Item on a system restart?

Because, the state of the Item will not be OFF at startup, but rather NULL or null (I’m not quite sure what the technical difference is between those, but I understand that there is a difference.)

You might want to flip the IF logic to account for this.

Something like…

rule “Rolladen hoch bei Sonnenaufgang”

when

Channel ‘astro:sun:local:civilDawn#event’ triggered START

then

if (Rolladensteuerung_AnAus_Switch.state == ON) {

Rolladen_ALLE.sendCommand(1)

 Rolladen_Hauswirtschaftsraum_BlindsControl.sendCommand(100)

}

End
1 Like