Rules in OH3 UI: "But only if" outside a specific timeframe

Hello all,

after having lots of rules in .rules files I now started building my first simple rules in the new OH3 rule UI. I am struggeling to create the correct “But only if” constraints. My rule should only all day except between 8pm and 9pm. It looks like the time condition does not work with “21:00” as start time and “20:00” as end time, the rule never executes. On the other hand I cannot use “between 0:00 and 20:00” AND “between 21:00 and 23:59” as those will never true at the same time (and the but only if constraints are always combined with AND). Something like “if it is not between 20:00 and 21:00” would also work for me, but there is no NOT for time based constraints…

Any idea how I can do this?

Can you create a 2nd rule to disable the 1st at 8 and enable it at 9 (Cron based)

Why not using two rules with same content but different time frames ?

Question also was raised in this thread: Check "But only if" conditions with OR?

1 Like

Thanks, Wolfgang. I also thought about that solution before and yes it would work. But usually I think it’s a good idea to not duplicate code (maintainability, bug fixing, …). Therefore I was looking for a solution that works and follows good practice. However, I think the thread you linked has a valuable information that I overlooked before: the use of script for the condition. This way I can keep only one rule and can write the condition myself. I think this is a good combination / solution. Thanks for pointing me there.

1 Like