Astro binding offset

Hey, I want to use the Astro Binding events (astro:sun:local) to trigger our window blinds. I found that astro:sun:local:noon#start can be configured (in Paper UI) to have an offset, so I added an offset of -60

  - id: noon#start
    channelTypeUID: astro:start
    label: Startzeit
    description: Die Startzeit des Ereignisses
    configuration:
      offset: -60
      forceEvent: false

from the documentation I understood that this is in minutes.

but the triggered rule with the condition

triggers:
  - id: "1"
    configuration:
      thingUID: astro:sun:local
      event: ""
      channelUID: astro:sun:local:noon#event
    type: core.ChannelEventTrigger

is running at 13:13 - this is the calculated time of noon - without the offset.

Any idea what I need to add to have this running at 12:13 as expected?

Hi @ohmicha

Didn’t you set the offset to noon#start, but you are triggering for noon#event. How about also triggering for noon#start?

Also be aware that the solar noon is offset to 60 minutes later now because of daylight sav9ing time. Once that switches back to default time you’d likely want to get rid of the 60 minutes offset again. Maybe a better solution would be to trigger the blinds by the sun’s azimuth and altitude. That’s what I’m also doing for my roller shutters - at least during summer :slight_smile:

Thank you very much! I’ve changed this with the offset and find out tomorrow if that worked.

Also thank you for the hint with the daylight saving, I’ll dig into this and find out what sun’s azimuth and altitude means and how I can use this for my window blinds. :folded_hands:

I want to provide a little bit about why it didn’t work the original way. OH supports two different types of Channels: state channels and event channels. A state channel can be linked to an Item. An event channel can be used to trigger a rule without being linked to an Item (in fact you cannot link it to an Item without using a special profile).

The noon#start and noon#end channels are state channels. These can be linked to a DateTime Item and you can see the time on a UI or use it in a rule. But you are triggering the rule using the noon#event channel which is a separate channel. Therefore you need to configure the offset on the event channel, not the start channel.

Note, when using the Astro event channels, your rule will trigger at both the start and at the end of the event, so it will trigger twice. Depending on the event, there can be some minutes between the start and the end events. If you only want it to run for one of those, you can set a condition on the rule to see if the trigger is the start or the end event. Unfortunately it will take a script condition (the following is what it would be in JS):

event.event == "START"
1 Like

Dear Rich,

thank you for the explanation - I was already wondering why the rule is executed twice.

I tried and added the condition to the rule

triggers:
  - id: "1"
    configuration:
      thingUID: astro:sun:local
      event: ""
      channelUID: astro:sun:local:set#event
    type: core.ChannelEventTrigger
conditions:
  - inputs: {}
    id: "9"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: event.event == "START"
    type: script.ScriptCondition

but it seems as this now blocking the rule exexution.

You could also link the state channel (without any offset) to a date time item, then trigger using item time. The trigger allows an arbitrary offset to be specified

In Rules DSL there is no such thing as event.event. See Textual Rules | openHAB for what is available. In particular:

receivedEvent implicitly available in every rule that has a channel-based trigger.

The above code I posted is for JS, not Rules DSL. I noted as such but that may not have been completely clear.