Help please - Using an astro-binding trigger to fire a rule action on Raspbian (Light off at dawn)

  • Platform information:
    • Raspberry Pi 3B
    • Raspbian (OH 4.3.3 Release Build)

I want to turn off a light when the sun rises.

  • Installed astro-binding
  • Went to Local Sun Thing, and created a link on the channel Sunrise Start Time
  • Confirmed that Item AstroSunrise (DateTime.Point) exists in the Items list
  • Created the AstroSunrise rule below using the Design in the OpenHab UI

configuration: {}
triggers:

  • id: “1”
    configuration:
    itemName: AstroSunrise
    state: START
    type: core.ItemStateUpdateTrigger
    conditions:
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: OFF
    itemName: Front_Room_Uplight_Switch
    type: core.ItemCommandAction
  • inputs: {}
    id: “3”
    configuration:
    itemName: String_Lights_Switch
    command: OFF
    type: core.ItemCommandAction

The following entry shows up in my /var/log/openhab/events.log file

2025-03-27 16:09:00.005 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:astroDawn#event triggered START

The rule does not turn off the light.

Any help would be appreciated.

You probably want to use a Channel Event Trigger like this example triggering on sunset in Yakima.

configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: astro:sun:YakimaAstro
      event: START
      channelUID: astro:sun:YakimaAstro:set#event
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: console.log("Yakima sunset");
    type: script.ScriptAction

Yup - that’s it. Had it working until repeated power interruptions here crashed my OH installation. (No backup). I have not tested this yet, but I am sure this is the right solution, as it is what I had used before. But I could not recall how to get to the THING CHANNELS from the Design UI. Thanks John!

To my future self:

In the Rules Design UI:

  • When
    → Thing Event → Local Sun → a trigger channel fired
    Channel
    ->astroDawn#event (Range Event)
    Event
    → START

Code page shows the following:>

configuration: {}
triggers:

  • id: “4”
    configuration:
    thingUID: astro:sun:local
    channelUID: astro:sun:local:astroDawn#event
    event: START
    type: core.ChannelEventTrigger
  • id: “1”
    configuration:
    thingUID: astro:sun:local
    channelUID: astro:sun:local:astroDawn#event
    event: START
    type: core.ChannelEventTrigger
    conditions:
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: OFF
    itemName: Front_Room_Uplight_Switch
    type: core.ItemCommandAction

Actually, the rule did not fire. Help please. Here is the code.

configuration: {}
triggers:

  • id: “1”
    configuration:
    thingUID: astro:sun:local
    event: END
    channelUID: astro:sun:local:rise#event
    type: core.ChannelEventTrigger
    conditions:
    actions:
  • inputs: {}
    id: “3”
    configuration:
    command: OFF
    itemName: node_33__Front_Room_Uplight_Switch
    type: core.ItemCommandAction
  • inputs: {}
    id: “2”
    configuration:
    command: OFF
    itemName: ZWave_Node_034_DZ15S_Scene_Capable_Push_OnOff_Switch
    type: core.ItemCommandAction
  • inputs: {}
    id: “4”
    configuration:
    itemName: node_35__Patio_String_Lights_Switch
    command: OFF
    type: core.ItemCommandAction

And here is my log.

2025-03-30 13:31:00.005 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:rise#event triggered END

One other strange thing about the log entries is that they appear to be in UTC even though the machine TZ is set for EDT. Any idea what that is about?

openhabian@openhabian:/var/log/openhab $ date
Sun Mar 30 04:42:23 PM EDT 2025

There’s something odd there. All of your actions seem to be in the triggers section? Can you post using the code fences? This button:
image

And post both your events and openhab log at the time the event occurs. Add a logging action in your rule.

There are many, many recent posts on timezone issues. For example, see:

You need your EXTRA_JAVA_OPTS set properly.

Thanks - here is the code with code fences. I will look into the posts you mentioned.

configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: astro:sun:local
      event: END
      channelUID: astro:sun:local:rise#event
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "3"
    configuration:
      command: OFF
      itemName: node_33__Front_Room_Uplight_Switch
    type: core.ItemCommandAction
  - inputs: {}
    id: "2"
    configuration:
      command: OFF
      itemName: ZWave_Node_034_DZ15S_Scene_Capable_Push_OnOff_Switch
    type: core.ItemCommandAction
  - inputs: {}
    id: "4"
    configuration:
      itemName: node_35__Patio_String_Lights_Switch
      command: OFF
    type: core.ItemCommandAction

Ahh - this is a change - needing to set the timezone in the java opts file. Thank you! (This is the problem with having spent many weeks on Openhab a number of years ago getting things going, and then not keeping up with changes (becuase life happens). Here is my options now. I am lazy and just assumed that America/NewYork is valid syntax. I hope so. If not, I will change it to America/New_York.

EXTRA_JAVA_OPTS="-Xms192m -Xmx384m -XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true -Duser.timezone=America/NewYork"

UPDATE: looks like it worked, but I do need to change it to America/New_York.

2025-03-30 19:03:52.351 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'America/New_York'.

Thanks for your help. I imagine that the rule was working perfectly, but was executing on Berlin time when I was asleep. I added a logging message in the rule and will check it tomorrow.