[SOLVED] Open rollershutters based on astro binding with offset does not work

Dear community, I have installed the astro binding as well as a somfy tahoma binding to control my rollershutters. Controlling them works like a charm, so now I want to open and close them during the course of the day based on the astro events. Hence I created a rule for that. This worked as well, but rollershutters are opening way to early and close too soon. So I checked the astro binding again and came up with creating an additional astro thing with an offset. The setup worked well and the items show the proper offset time of day. However the event activitiy (Start / End) still run on the regular time.

Here is what I have done:

  1. Create an astro thing with a given offset
    //Things Astro
        Thing astro:sun:sunset_offset "Sonnenaufgang mit Offset" [geolocation="XX.XXXXXXX,XX.XXXXXXX,98", interval=60 ] {
            Channels:
                Type rangeEvent : rise#end [
                    earliest="07:00",
                    latest="08:30"
                ]
                Type rangeEvent : set#end [
                    earliest="22:00",
                    latest="00:00"
                ]
        }
  1. I create items based on the offset thing
DateTime Astro_Sonnenaufgang_Ende_Offset "Endzeit Sonnenaufgang [%1$tH:%1$tM Uhr]" {channel="astro:sun:sunset_offset:rise#end"}
DateTime Astro_Sonnenuntergang_Ende_Offset "Endzeit Sonnenuntergang [%1$tH:%1$tM Uhr]" {channel="astro:sun:sunset_offset:set#end"}
  1. I checked the new items compared to the original ones (without offset) (e.g. for sunrise end)

  2. I created a rule to run rollershutters based the astro offset (e.g. sunrise end)

//Rule Sonnenaufgang
    //Rollläden öffnen mit Sonnenaufgang (Offset), Schalfzimmer nur, wenn niemand zuhause ist
        rule "Rollläden Sonnenaufgang"
        when
            Channel "astro:sun:sunset_offset:rise#event" triggered END
        then
            logInfo("Rule Log", "Regel - Rollläden Sonnenaufgang - ausgeführt")
            if (Gruppe_Anwesenheit.state == OFF) {
                Rolladen_SZ_Steuerung.sendCommand(UP)
            }
            Rolladen_WZ_Terrasse_Steuerung.sendCommand(UP)
            Rolladen_WZ_Sofa_Steuerung.sendCommand(UP)
            Rolladen_Sportzimmer_Steuerung.sendCommand(UP)
            Rolladen_EZ_Steuerung.sendCommand(UP)
            Rolladen_Buero_Steuerung.sendCommand(UP)
            sendNotification("MAILADDRESS", "TEXT")
        end

Now I would have expected the rule to run at the offset time of e.g. T07:00:00.000+0200 as shown in the screenshot above.
However if I check my log, the rule triggered at the original time which is T05:27:00.000+0200. Please see screenshot:

I also checked the events and saw, that they both happened at almost identical time:

Can someone explain, what I am doing wrong and what needs change?

I use the UI and I did an example here:

It may help you?

Have you specified an offset on the event channels, rise#event and set#event?

You both lead me to specifying an offset not just for the END/START but rather for the whole event. I don’t quite get, how this works just from a theoretical thinking (I get how to do it though). Maybe you can explain it to me.

If I apply an offset to END/START, it is quite clear, that it moves the actual point in time (e.g. START - 30 minutes) or specifies an particular statement for EARLIEST/LATEST. But how does an event be affected by this? An event is a duration like From-To, or not? How can you apply an offset to this time period? I do not get it, sorry.

The offset only affects the channel it’s configured on. If you would have linked an Item to e.g. the rise#start channel, that would display the original time without offset applied, since that’s only configured on the rise#end channel. Same goes for rise#event.

Have you tried following the example in the link or are you still trying to use the files?
Personally I find the UI easier and less confusing and less prone to errors.
Don’t put anything in the earliest and latest. Leave that blank.
As far as the files goes, sorry can’t help you there.

Okay, understood. But isn’t that, what I have done? I have specified the offset for the channel rise#end as you can see in the things-file (or also in the UI):

Type rangeEvent : rise#end [
                    earliest="07:00",
                    latest="08:30"

So from my point of view, this channel is specified adequately. Then I created a rule:

        rule "Rollläden Sonnenaufgang"
        when
            Channel "astro:sun:sunset_offset:rise#event" triggered END
        then
            logInfo("Rule Log", "Regel - Rollläden Sonnenaufgang - ausgeführt")
            if (Gruppe_Anwesenheit.state == OFF) {
                Rolladen_SZ_Steuerung.sendCommand(UP)
            }
            Rolladen_WZ_Terrasse_Steuerung.sendCommand(UP)
            Rolladen_WZ_Sofa_Steuerung.sendCommand(UP)
            Rolladen_Sportzimmer_Steuerung.sendCommand(UP)
            Rolladen_EZ_Steuerung.sendCommand(UP)
            Rolladen_Buero_Steuerung.sendCommand(UP)
            sendNotification("Mailaddress", "Text")
        end

But, I use the rise#event channel, where I have not specified any offset, if I understood it correctly. So if I change this line as follows:

        when
            Channel "astro:sun:sunset_offset:rise#end" triggered

Would that then be correct and work along the specified offset?

I can follow the explanation of the post, no worries. But I still got a question to that.
The following channel:

Channel "astro:sun:sunset_offset:rise#event"

Will always trigger twice, correct? Once it triggers “START” and once it triggers “END”. As you can also see in the log.

Where does the offset apply to? Does it move the START or the END timeslot?

No, each channel group (e.g. rise) have four different channels: #start, #end, #duration and #event, all with separate configurations. You have only configured the #end channel.

You have limited the rise end event to only be fired between 7:00 and 08:30. Your rule will not start outside that timeslot.

Okay, now replying to both of you @pacive and @hmerk. Sorry if I keep asking stupid questions. :slight_smile:

  1. I specified the offset for the #end channel, as you can see above in post #7. I agree.
  2. I then created a rule, which shall fire once channel #event triggered END.

So having the rule react to #event is not what I want, as I did not specify any offset for that channel. So I need to adjust as mentioned as well in post #7?

rule "Rollläden Sonnenaufgang"
        when
            Channel "astro:sun:sunset_offset:rise#end" triggered
        then
            logInfo("Rule Log", "Regel - Rollläden Sonnenaufgang - ausgeführt")
            if (Gruppe_Anwesenheit.state == OFF) {
                Rolladen_SZ_Steuerung.sendCommand(UP)
            }
            Rolladen_WZ_Terrasse_Steuerung.sendCommand(UP)
            Rolladen_WZ_Sofa_Steuerung.sendCommand(UP)
            Rolladen_Sportzimmer_Steuerung.sendCommand(UP)
            Rolladen_EZ_Steuerung.sendCommand(UP)
            Rolladen_Buero_Steuerung.sendCommand(UP)
            sendNotification("Mailaddress", "Text")
        end

Correct?

But checking my log files, the channel rise#end does not trigger anything at all. I can’t find it. I only find the channel rise#event triggering something (START and END).

No, the #event channel is the only one that is a trigger channel, i.e. can be used as a rule trigger. So you HAVE to configure the offset on this channel if you want the rule to be triggered according to the offset.

Edit: this is my config:
The rise#end channel has no offset configured, and displays the actual time of the sun rise.

However, the rise#event channel has an offset of 60, so it will always trigger 60 min after that time.

From the docs :

rule "example trigger rule"
when
    Channel 'astro:sun:home:rise#event' triggered START
then
    ...
end

But as said, you have limited it to only be fired between 07:00 and 08:30 !

This form of rule trigger is looking for a channel trigger event.

But rise#end is not an event channel. It is a state channel. You can tell this because you can link it to a Datetime Item.

At midnight, Astro binding works out times for the day ahead, and updates state channel rise#end to 06:30 or whatever. An Item linked to that channel stays at 06:30 until next midnight, nothing happens with it, you can’t use that for triggers.

Channel rise#event is a trigger event channel. It’s a completely different type, you can’t link it to an Item because it has no state at all. It just triggers events once in a while, events called START or END.

So you need to change your rule trigger from
astro:sun:sunset_offset:rise#end
to
astro:sun:sunset_offset:rise#event

To apply an offset to the event

Type rangeEvent : rise#event [
                    earliest="07:00",
                    latest="08:30"

Note that you have to offset the whole event, you cannot offset START and END individually.

What you do with the event does not affect the state channels, independent offsets.

Simple summary: if you don’t see the word event in your trigger and in your offset, you’ve got it wring.

2 Likes

Okay, all understood. Thanks @rossko57 for the explanation. To just check, if I got it correctly.

Let’s say:

  1. I specified the offset for an event as mentioned by @rossko57 to be earliest=“07:00” and latest=“08:30”. The regular state for rise#start is 06:45 and the regular state for rise#end is 08:15
  2. As a result, the trigger of rise#event will fire for START at 07:00 (based on the offset) and for END at 08:15 (offset won’t have any impact here)

Is that correct?

Am I assuming right, that if I want various offsets for END (let’s say earliest 08:30), I would have to create an additional astro thing and place the right offset in the rise#event here yet again.

Is that also right?

Don’t think so. You cannot offset the individual components of an event/trigger channel, only the whole event.

If you offset +10 say, both START and END events get +10.
If you “earliest” 07:00 say, neither START nor END will take place before 07:00. If they both ‘naturally’ fall before 07:00, I think you’ll get both in millisecond quick succession at 07:00

Sunrise START and END events are normally just a few minutes apart, the time it takes the Sun’s disc to cross the horizon.

Yes, e.g. a weekday earliest Thing and a weekend earliest Thing.

EDIT - reading again, I don’t think you’ve grasped it yet

It doesn’t matter what you do to rise#start and rise#end, these are state channels and it will only affect what you see in linked Items.
This does not affect rise#event at all
If you want rise#event to have earliest/latest, you have to tell it.
When you do …
This does not affect rise#start or rise#end at all
it’s all fully independent.

I think I got it, @rossko57. It is maybe my misleading English to tell exactly, what I understood.

So here is, what I’ve done now:

  1. Setting offset at the rise#event and the set#event channels like:
Thing astro:sun:sunset_offset_week "Sonnenaufgang mit Offset Werktag" [geolocation="XX.XXXX31765844546,XX.XXXX60934829714,98", interval=60 ] {
            Channels:
                Type rangeEvent : rise#event [
                    earliest="07:30",
                    latest="08:00"
                ]
                Type rangeEvent : set#event [
                    earliest="22:00",
                    latest="00:00"
                ]
        }

The offset is well reflected in the UI as well.

  1. Now create a rule, telling OH3 what to do - like:
rule "Rollläden Sonnenuntergang"
        when
            Channel "astro:sun:sunset_offset_week:set#event" triggered END
        then
            logInfo("Rule Log", "Regel - Rollläden Sonnenuntergang - ausgeführt")
            if (Gruppe_Anwesenheit.state == OFF) {
                Rolladen_WZ_Terrasse_Steuerung.sendCommand(STOP)
            }
            Rolladen_WZ_Sofa_Steuerung.sendCommand(STOP)
            Rolladen_Sportzimmer_Steuerung.sendCommand(STOP)
            Rolladen_EZ_Steuerung.sendCommand(STOP)
            Rolladen_Buero_Steuerung.sendCommand(STOP)
            Rolladen_SZ_Steuerung.sendCommand(STOP)
            logInfo("Rule Log", "Regel - Rollläden Sonnenuntergang - durchgeführt")
            sendNotification("Mailaddress", "Rollläden bei Sonnenuntergang schließen")
        end

Now the rollershutter at sunset shall close, if the set#event triggerd END.
END as trigger of set#event will be earliest at 10PM and latest at midnight. Or, if the regular state is somewhere in between, it will fire in between.

Correct?

1 Like

You’ll find out :wink:

Only if you apply an identical offset to the separate state channels, I think.
Bear in mind the state channels only get recalculated at binding restart or midnight.

I will - for sure. But I am more confident now. :wink:

And yes, I restarted the Raspi already.

Will let you guys know latest by tomorrow.

Thanks for now to:
@rossko57
@pacive
@hmerk
@ubeaut
:ok_hand: :raised_hands:

Worked like a charme. Sunset and sunset fired at the expected time. Excellent.

Thanks again to:
@rossko57
@pacive
@hmerk
@ubeaut

1 Like