Triggering action at dusk (with astro-binding)

I’d like to activate my roller shutters at dusk for which astro-binding seems to be the way. So I created an channel/item “Dusk” which delivers something like “2021-04-19T21:40:00.000+0200”.
One (probably unnecessary complicated) way to proceed might be: (Javascript, I don’t know Java at all)rule which triggers every minute →

if (Date.now() == parseInt(items["Dusk_Start"])) { ACTION;}

The problem is that Date.now and Dusk_start don’t fit together; date.now delivers milliseconds, dusk something else entirely. With a lot of hassle I could possibly extract hours and minutes of both and compare them.
But I’m sure for such a common request there is a much simpler solution. Could you tell me which?
(By the way, I only have (limited) experience with OH3, no OH2)

Why not just use one of the event channels (astroDusk, nauticDusk, civilDusk, etc/) as a trigger for the rule?
For example,

rule "Sunset"
when
    Channel 'astro:sun:local:civilDusk#event' triggered START
then
   ...
end
1 Like

This looks quite like the thing to do, but I’m totally unfamiliar with that. Looks like some OH2-approach to me; where would I write such text?
I’m working with this environment:


The code would look something like this:

triggers:
  - id: "1"
    configuration:
      itemName: Dusk_Start
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: //run some action
    type: script.ScriptAction

Do you know how to transform your idea to this environment?

Add a trigger. Choose a Thing event. Select your Astro Thing from the list and choose the event you want to trigger the rule.

Beyond that, you should use ZonedDateTime for your Time based operations. Then you can do something like:

if(ZonedDateTime.now.isAfter(items["Dusk_Start"].getZonedDateTime())) {
2 Likes

Thank you Rich, good to know!