Astro Binding and weekend

Hello everybody,
I have installed several roller shutters in the house. The one in the bedroom should open the blind a later at the weekend. Besides, I like the idea that the blinds open depending on astro time (civil dawn), but not later than predefined time.

So I have these things defined:

Thing astro:sun:wochenende "Rolladenöffnung Wochenende" [geolocation="50.7,7.1", interval=60]
{Channels:
    Type rangeEvent: rise#event 
    [
        earliest="08:30"
    ]
}
Thing astro:sun:wochenende "Rollandenöffnung Wochenende" [geolocation="50.7,7.1", interval=60]
{Channels:
    Type rangeEvent: rise#event 
    [
        earliest="07:00"
    ]
}

But how do I decide whether it is weekend or not? I thought this rule would be a good idea:

rule "Rolladen rauf"
when
    (Channel 'astro:sun:nicht_wochenende:rise#event' triggered START) and (Ephemeris.isWeekend())
then
    Rolladen_Esszimmer.sendCommand(UP)
    Rolladen_Wohnzimmer.sendCommand(UP)
    Rolladen_Wohnzimmer_S.sendCommand(UP)
    Rolladen_Arbeitszimmer.sendCommand(UP)
    Rolladen_SZ.sendCommand(UP)
end

Unfortunately this is followed by an error

[{
	"resource": "/run/user/1000/gvfs/smb-share:server=openhab.local,share=openhab-conf/rules/Rolladen.rules",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "org.eclipse.xtext.diagnostics.Diagnostic.Syntax",
	"severity": 8,
	"message": "no viable alternative at input '('",
	"startLineNumber": 55,
	"startColumn": 5,
	"endLineNumber": 55,
	"endColumn": 6
}]

Of course I have to set up another rule to open the blind outside the weekend…
But this error is annoying me. Any idea?

Thanks in advance,
Ulrich

I am running openhabian 3.2 on a raspberry pi.

I think you need to check Ephemeris.isWeekend() directly in your code since it’s not a channel nor an item which could be used as a trigger

Triggers are OR only, you cannot AND them. I’m not sure you can surround them in quotes either - that’s what the error is complaining about, I presume.

And as @Sascha_Billian says, the ephemeris one is not a trigger - check that one in the code itself using an IF, ELSE statement. You might be able to do the weekend and weekday logic in a single rule that way, depending on what you want to ultimately achieve.

OK, isWeekend is not a trigger and can’t be written in a “when”-statement. But then this piece of code should work, shouldn’t it?

rule "Rolladen_SZ_wochenende_rauf"
when
    Channel 'astro:sun:wochenende:rise#event' triggered START
then
    if Ephemeris.isWeekend
    then
        Rolladen_SZ.sendCommand(UP)
    end
end

But then I receive this error (the 1st of 4):

[{
	"resource": "/run/user/1000/gvfs/smb-share:server=openhab.local,share=openhab-conf/rules/Rolladen.rules",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "org.eclipse.xtext.diagnostics.Diagnostic.Syntax",
	"severity": 8,
	"message": "missing '(' at 'Ephemeris'",
	"startLineNumber": 79,
	"startColumn": 8,
	"endLineNumber": 79,
	"endColumn": 17
}]

There is no difference between “Ephemeris.isWeekend” and “Ephemeris.isWeekend()”.
What is wrong with this?
Thank you,
Ulrich

The rules language has a syntax. Have you looked at other examples?
if() requires you to use ().
then and end are part of rule triggering structure, and not used with if()

when
    Channel 'astro:sun:wochenende:rise#event' triggered START
then
    if (Ephemeris.isWeekend) {
        Rolladen_SZ.sendCommand(UP)
    }
end

I looked for an example but didn’t find one. It is very difficult to search for “if”… :wink:
There are no more syntax errors now, i hope it will work now.
Thanks a lot!
Ulrich

Note that you have defined one Thing twice - same UID astro:sun:wochenende.
I think the second entry will “win”.

Thank you for your attention. In fact, I defined the things astro:sun:wochenende (weekend) and astro:sun:nicht_wochenende (not a weekend). It should work this way. I have no idea why I posted the same thing twice.
Once again: Thank you!

1 Like