Trigger rule on DateTime item

hello Community,

Is it possible to trigger/start a rule on a specific Time, coming from an variable DateTime item (e.g. astro-items) ?? I couldn’t find anything in the documents.

Thank you

Can you elaborate what you want to do ? that will make it easier to point you in the right Direction ?

It’s awfully complicated so you won’t want to do it.
The astro binding generates events on every possible occasion, that’s way easier to trigger upon.

1 Like

This is what I’m trying to accomplish

Item:

DateTime AstroDaylightEnd "[%1$ta, %1$td.%1$tb %1$tY -- %1$tR]"{channel="astro:sun:local:daylight#end"}

Rule:

rule "Irrigation start/stop"
  when
    Time Item AstroDaylightEnd ??.....??
  then
     do something

i use the following for day/night controll of my outside ligts.

with my rule :

rule "Stoep Light On"
when
    Item vTimeOfDay changed to "EVENING"
    
then
 if (Alarm_Status.state == "Disarmed") {
  Kitchen_Light_Stoep.sendCommand(ON) }
 if (Alarm_Status.state == "Armed-Stay") {
  Kitchen_Light_Stoep.sendCommand(ON) }
 if (Alarm_Status.state == "Armed-Away") {
  Kitchen_Light_Stoep.sendCommand(ON) }
 
end
    
rule "Stoep Light Off"
when
    Item vTimeOfDay changed to "BED"
   
then
 if ( Alarm_Status.state == "Armed-Stay" ) {
  Kitchen_Light_Stoep.sendCommand(OFF) }
 if ( Alarm_Status.state == "Disarmed" ) { 
  sendBroadcastNotification("Stoep Light Still On" + " - " + now.toString("MM/dd HH:mm ")) }
 
end

rule "Stoep Light Off Armed"
when
    Item vTimeOfDay changed to "MORNING"
then
 if ( Alarm_Status.state == "Armed-Away" ) {
  Kitchen_Light_Stoep.sendCommand(OFF) }
end

Not sure if this would help you. My Rule is still crude. but it is a work in progress as i am only beginning to use rules now.

So according to https://community.openhab.org/t/design-pattern-time-of-day/15407

this might be a solution. I’ll try this out

rule "Calculate time of day state" 
when
  System started or // run at system start in case the time changed when OH was offline
  Channel 'astro:sun:home:rise#event'    triggered START or
  Channel 'astro:sun:home:set#event'     triggered START or
  Channel 'astro:sun:minus90:set#event'  triggered START or
  Time cron "0 1 0 * * ? *" or // one minute after midnight so give Astro time to calculate the new day's times
  Time cron "0 0 6 * * ? *" or
  Time cron "0 0 23 * * ? *"
then

  logInfo(logName, "Calculating time of day...")...........
when
  Channel 'astro:sun:mythingname:set#event' triggered START
then

or trigger upon any of the other events, many to choose from - see binding docs.

Note you can also create multiple astro things, each to have a different offset.

The DP rules Calculate the TOD
and you use that in your rule. read the whole design patern. i use the rules in the design and items . then i wrote my rule to look at the vtime of day. as my trigger and then it has actions.