[Solved] Using 'or' in OH2 rule definition

I’ve migrated most of my existing OH1 rules and scripts across to OH2 and it all seems to be running quite happily. I have 1 scenario that I can’t get to work. In OH1 I had a rule to control starting a dehumidifier (called Artoo). There is also a matching off rule that follows the same format. This is actually the first thing I ever did in OH way back, so it has been working for a long time in OH1.

//Start Artoo
rule "Start Artoo"
when
	Time cron "0 30 6 * * ? *" or 	//06:30 everyday
	Time cron "0 30 18 * * ? *" 	//18:30 everyday
then
	//turn Artoo on
	sendCommand(Switch_FF_Guest_Artoo,ON)
	
	Item_Notify_Message.postUpdate("Artoo On")
end

I moved this rule across to OH2, but no matter what, I cannot get the second instance time to fire. Artoo goes on quite happily at 06:30 and stops at 09:30 (as per second rule). Nothing happens at 18:30 (or 20:30) - Artoo doesn’t start and I get no indication in the logs that the rule has even been attempted at these times.

I’ve tried re-formatting the when statement:

Time cron "0 30 6 * * ? *" or Time cron "0 30 18 * * ? *" 	//06:30 and 18:30 everyday

I’ve tried different cases:

Time cron "0 30 6 * * ? *" OR Time cron "0 30 18 * * ? *" 	//06:30 and 18:30 everyday

Tried logical symbols in both layouts:

Time cron "0 30 6 * * ? *" || Time cron "0 30 18 * * ? *" 	//06:30 and 18:30 everyday

Removed the comments:

Time cron "0 30 6 * * ? *" or 
Time cron "0 30 18 * * ? *"

Nothing fires the second instance. I pretty sure it’s not the cron as they both follow the same format.

What am I missing?

There is currently a bug in OH 2 where a rule with multiple Time triggers do not work correctly. A temporary workaround would be to combine the two into one trigger (cron is awesome that way):

Time cron "0 30 6,18 * * ? *"
1 Like

Thanks for that, in some ways I’m glad it’s a bug… it means I’m not being stoopid!:stuck_out_tongue_winking_eye:

I’ll change the rules…

oh thanks! I’m also just despaired on this one!

Time cron "0 45-59 05 * * ?" or
Time cron "0 */1 6 * * ?" or
Time cron "0 1-15 07 * * ?"

I’m not the cron-guy, is there a way to have a cron every Minute from 5:45 till 7:15 in one line?

Thanks,
Thomas.

I don’t think so. I think you are restricted to whole hour boundaries. But have a play here to see how close you can get!

Thanks. For the time being, I’ll stick with:

Time cron "0 */1 5-7 * * ?"