bgilmer
(Brad Gilmer)
March 27, 2025, 5:28pm
1
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.
jswim788
(John Schmitz)
March 27, 2025, 5:43pm
2
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
bgilmer
(Brad Gilmer)
March 27, 2025, 6:29pm
3
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
bgilmer
(Brad Gilmer)
March 30, 2025, 8:50pm
4
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
jswim788
(John Schmitz)
March 30, 2025, 9:53pm
5
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:
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:
Last week I upgraded openHAB to 4.2.1. I then started with a clean openHABian 1.9 (64 bit from the Raspberry Pi Etcher) to move to the new version. Since I did this, openHAB is using UTC time instead of local time. My dear wife asked me why the outside lights turned on at 2 AM local time and didn’t turn on in the evening, which caused me to look into it.
The entries in the events and openhab logs are time stamped with UTC times. The Astro binding is using these times, which has messed up my…
You need your EXTRA_JAVA_OPTS set properly.
bgilmer
(Brad Gilmer)
March 30, 2025, 10:55pm
7
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
bgilmer
(Brad Gilmer)
March 30, 2025, 10:58pm
8
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'.
bgilmer
(Brad Gilmer)
March 31, 2025, 12:28am
9
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.