Rule for Roller Shutter via Astro Binding an Paper UI/rule engine

Tags: #<Tag:0x00007f6169a52680> #<Tag:0x00007f6169a524c8> #<Tag:0x00007f6169a52400>

Hi,
I’m runing openhabian (newest version / updated and upgraded yesterday) on a raspy 1.
I’ve installed the astro- and the z-wave - binding. They both work “as far”. Although i’ve searched the forum, the docs and the internet i’ve not found the correct syntax to create a rule (via rule engine) to combine the astro binding with my rollershutter.

the aim is to send the rollershutter up at sunrise and to send them down at sunset.

Problem is in the “when”- requirement. I’ve tried all the “item”-based when-Requirements (an item state, an item state is updated, even “an item receives a command”). … but all the status (up, on, …) won’t work. I think i need a status “Start” - but this is not given.

actually i just need a functioning example of a astro binding thing, channel, item in the paper ui rule engine.

Thanks in advante

Tom

Post your items and the rule please.
Does it work, if you use a UserInterface?

Simplified from Design Pattern: Time Of Day

rule "test"
when
    Channel 'astro:sun:home:rise#event' triggered START
then
    // do stuff at sunrise
end

The Channel name needs to exactly match your Thing ID. I think the autodiscovered Thing ID is usually astro:sun:local.

Hi,
as always a great, quick reply/solution - thank you. But this time i want to try the rules engine. Hier ist my (not working) “clicked” rule:
overview (simple “when”/“then”):
image

first the “THEN” (because this working/correct):

problem ist the “WHEN” - first try: here the try with “trigger channel fires”
image

second try: here with “item state ist updated”
image

Any idea why my rules won’t work?

Thanks in advantage

Tom

Hi,

Using this rule to close all blinds DownStairs (all blinds are added to the group DownStairsBlinds and DownStairsBlindsLam respectively.

rule "Close DownStairs blinds at night"
 when
  Channel 'astro:sun:home:set#event' triggered START
 then
  if( WindHigh == false && AlarmON == false && FireON == false)
  {
   gDownStairsBlinds.members.forEach[BlindsControl | BlindsControl.sendCommand(BlindsClosed)]
   gDownStairsBlindsLam.members.forEach[LamellaPosition | LamellaPosition.sendCommand(blindLamella0)]
   logInfo ("StatusUpdate", "Closing DownStairsBlinds for night")
  }
end

and this is the thing definition for the triggers:

astro:sun:home "Sonnenstand" @ "Zuhause" [ geolocation="47.959284,16.524280", altitude=186, interval=60 ]
{
    Channels:
        Type rangeEvent : set#event [
            offset=45,
            latest="22:00"
        ]
}
astro:sun:upstairs "Upstairs" @ "Zuhause" [ geolocation="47.959284,16.524280", altitude=186, interval=60 ]
{
	Type rangeEvent : set#event [
	    offset=45,
            latest="19:15"
	]
}
astro:sun:terrasse "Terrasse" @ "Zuhause" [ geolocation="47.959284,16.524280", altitude=186, interval=60 ]
{
        Type rangeEvent : set#event [
            offset=150,
            latest="23:30"
        ]
}

To illustrate the use of different trigger points (time-of-day) - the rule for UpStairs blind:

rule "Close UpStairs blinds at night"
 when
  Channel 'astro:sun:upstairs:set#event' triggered START
 then
  if( WindHigh == false && AlarmON == false && FireON == false)
  {
   gUpStairsBlinds.members.forEach[BlindsControl | BlindsControl.sendCommand(BlindsClosed)]
   gUpStairsBlindsLam.members.forEach[LamellaPosition | LamellaPosition.sendCommand(blindLamella0)]
   logInfo ("StatusUpdate", "Closing UpstairsBlinds for night")
  }
end
2 Likes

Hmm, never tried to “click” rules. As @rlkoshak replied, this is experimental and you better should not go for it. Too much uncertainty, too little users able to help you with.
Better use a text editor to create .rules files. Don’t edit them in place but copy them there once you think you’re done editing.
Check openhab.log for syntax errors whenever you copy or edit them.

Here’s a complex rule to automate shading you can peek at.

Hello,
I have exactly your combination, Z-Wave RollerShutter with Astro Binding controlled by the new UI Rule engine. And it is working.

WHEN…
Updat trigger: a trigger Channel fires ; React on events form a trigger channel of a thing
Channel: Asto sun data (civilDusk#event)
Event: END

THEN…
Update action: Send a comman to a specific item
Item: Bilinds Control
Command: DOWN

Pleas find my screenshots in the following pics:
image
image

Note, what I posted is code for the Rules Engine. What you are showing screen shots of is the Experimental Rules Engine sometimes called Next Generation Rules Engine. It is called “experimental” for a reason. It is not yet complete and documentation for it is lacking. If you want to use this engine you are largely on your own at this point.

Not really, except that in the Rules Engine one usually uses “START” all caps as the Event. Perhaps you need to do the same in the Experimental Rules Engine and use END.

Hi Rich,
thank you for the clarification of the wording.
Do you know, if there is support for the “old” Rules Engine in the latest Paper UI.
I’m asking because I did not find it in Paper UI, only the new Rules Engine (Experimental) is an installable Add-on .

Well it’s not just wording but a substantial difference. “The” (“old”) rules engine works well and everyone’s using it while likely noone will be able to support with the experimental one and clearly no beginner should try. No you cannot access the rule engine from PaperUI.
You could install ESH Designer which provides support to create rules in graphical form, but noone’s really using that either.
In the end, rules are text, so everybody goes for textual editing sooner or later anyway, so while you probably don’t want to hear that, better start there right away. Most common advice is to use VS code extensions, see [here].(https://docs.openhab.org/configuration/editors.html).

Hi,
o.k. i’m no developer but mastered some rules via nano. Maybe it’s time to do the next step: i’ve installed Visual Studio Code now; also the openhab-extension. … and … and. … mmh - is it still correct to connect to my openhabian-raspberry via samba (like '2013: How to set up visual studio with openhab extension with samba?) … or is there a comfortable assistent-function meanwhile?

Thanks in advantage
Tom

Depends on your setup. For VS code extension to run on Windows, yes you need file level access so you need to share your openHAB’s box rules directory somehow, and the easiest way is Samba.
You could of course also use nano or vim locally on your OH box, but then you don’t get the syntax checking etc.

There is no support for it in PaperUI. The Rules Engine is just there. There is nothing extra to install and PaperUI has nothing to do with it at this time (PaperUI is always growing, perhaps someday?).

I thought that was only in Habmin. I don’t remember there being a graphical rules builder in ESHD. Though the point is still the same, neither ESHD nor the Rules builder in Habmin have been updated and are horribly out of date with the latest OH and should not be used.

o.k. the rules via “clicking”/Experimental Rules Engine haven’t worked - but a rule via Standard-Editor (NANO in my case) worked for the channel “civilDawn”. If the “civilDusk”-rule works as well this evening i will mark this topic as “solved”.
But by the way: can anyone tell my what “civilDusk/civilDawn” really means? where ist the difference to sunrise/sunset?


The start of each marks the beginning and the end marks the end of the twilight period for each of the different ways to calculate sunrise and sunset.

At the high level, the differences have to do with where the center of the sun is relative to the horizon that determines when the event starts.

According to the Wikipedia article Astro dawn starts first (center of the sun is 18 degrees below the horizon) and ends when Nautical dawn starts (12 degrees below the horizon) and that ends when Civil dawn starts (6 degrees below the horizon) and everything ends when the center of the sun reaches the horizon (0 degrees).

Assuming the Astro library and the wikipedia article are in agreement, I would assume that the Astro library is using 0 degrees for sunrise and sunset.

I think most people around here use civil dawn and dusk.

I never looked into this before. It was a nice rabbit hole to go down.

Thanks for revealing this last secret … Topic is done.