Need help for a rule trigger

Hey Folks,
i need help or tipp.

I want to trigger a rule on exactly Date (01.January every Year) and on this date a light goes on.

Is it possible to map these attitudes?

THX

Happy new year!

Time cron 0 0 0 1 1 ?

If you read through the docs, there are some links to some cron expression generators.

Thanks but I could have done that too.
What I want: When I turn on the lights on a certain day.

Something is supposed to happen if I turn something on that day.

This cron generator may be mentioned in the link provided by Scott but if not here is a good one that I keep bookmarked. :wink:

https://www.freeformatter.com/cron-expression-generator-quartz.html

Use the cron time and in the rule use an if statement to check the condition and do something if the condition is true e.g. on the 1st day of the year and the light is on do something.

Example rule below is not using a cron time for a trigger but you can change the trigger.

var Timer lightTimer = null
rule "Front Porch Lights ON"
when
	Channel 'astro:sun:local:civilDusk#event' triggered START
then
	FrontPorch_Light.sendCommand(ON)
	OfficeLight.sendCommand(ON) 
end

rule "Garage Light ON Door Open"
when
	Item FrontPorch_Light changed to ON 
then 
	if(lightTimer === null){
			lightTimer = createTimer(now.plusMinutes(20)) [| 
				lightTimer.cancel()
                lightTimer = null
				if(Proxy_Lightlevel == OFF && Garage_Door.state == OFF){
					Echo_Plus_TTS.sendCommand('Please turn on garage light it is dark and the door is open') 
				} 
			] 
	} 
end 

Notice something only happens if the light level is off and the garage door is open.

Well… that is clearly not what you asked for…

In a Jython script, if you want to check if it is New Year’s Day…

if DateTimeType().zonedDateTime.getDayOfYear() == 1:
    # do stuff

In the rules DSL, this is easy, too:

if(now.getDayOfYear == 1) {
// do stuff
}

@Udo_Hartmann, Joda has been removed in OH 3.0, so that will no longer work. It is best to use ZonedDateTime.

Well, as OH3.0 will no longer provide the DSL anyway… :wink:

OMG😳, then I need to rewrite all my rules. <\sarcasticmode>

:stuck_out_tongue_closed_eyes: