Illuminance range as trigger

Hello,

I would like to use illuminance as a trigger, but I want to use it as a range.

Example: Illuminance of living room sensor is within range 60-80.

Yes, I know I can use things like changed and and then ask the question later. But, my rule has a wait for condition statement in it, and the constant re-triggers whenever lux changes are causing the timers to reset. I would rather not manually enter 30 triggers.

Can you set the illuminance as a set of predicates?

if illuminance > 59 and
if illuminance < 81

I did use a predicate to control it firing in the first place with a variable set off by another rule, so I suspect this could work. Once that releases is now the problem. Will a predicate changing to false while a timer is in progress cancel the a rule timer, or will it let the rule complete its actions and just prevent more triggers?

Predicates only affect Rule triggering: when the predicate is false, nothing will trigger the rule. Existing subscriptions, schedules, etc. created by your actions will remain as-is.

If you want to be more certain that what you're doing will work, I'd suggest sharing a screenshot or typed-out description of your Rule, along with what you expect to happen (in plain language, not thinking about implementation details). Otherwise, it sounds like you're pretty close as-is!

:slight_smile:

I expect a change of <=15 to trigger the rule. I expect it to then wait for five minutes to ensure lux stays within the range and fire off my rainy day scene.

I expect a change of >=65 to do the same but to turn the scene off.

I'd again recommend just describing what you want to happen, not how you want to do it in terms of implementation details. But it sounds like you want the scene activated if lux stays below 15 for 5 minutes, then off (plus the variable change) if it goes above 65 for more than 5 minutes? If so, here's one way you can do that without having the re-triggers be a problem for your "Waits":

Trigger: Lux <= 15

Predicate rule: Lux > 15

Actions to run:

Wait for rule: Lux <= 15 --> duration 0:05:00
Activate Scene: Scene - Rainy Day
Wait for rule: Lux >= 65 --> duration 0:05:00
Off: Scenes - Rainy Day
Set Rainy Day to False 

There are probably other ways to do it but this takes advantage of the predicate to only capture on the specific transition from Lux > 15 to Lux < 15. You don't need to trigger on higher values because the second "Wait" inside your Rule creates a subscription to this event, so the appropriate actions will happen then, should these actions be reached.

Yeah.. my controls designers at work tell me the same thing. I promise I am working on it, I appreciate you! So I notice that in my RM wait for condition is no longer around, unless I am just not looking. I now see "wait for rule. Is this the same thing?

Yes, Wait for rule is the same thing.

1 Like

So then @bertabcd1234, Can I ask why you wrote the first wait as event and the second wait as condition? Wouldn't I be waiting for a condition in both scenarios to evaluate truth?

I wrote it that way because it was an accident. :smiley: (Actually, I originally had a "Wait for event: elapsed time" before realizing that it won't quite handle the entirety of what you want.)

I also should have said "Wait for rule" instead of "Wait for condition(s)"--new-ish terminology for the same feature. Still getting used to that...ha. Edited the post to reflect this.

2 Likes

Thank You! I will write this now and report back after a couple days. I still owe you an update on my garage door time out. I sort of got side tracked with this one this weekend.

@bertabcd1234 This works! I tested it by covering the lux sensor. I was curious how the predicate would affect the trigger once the meter crossed below the threshold. I saw in the logs that first the trigger happened, the rule executed the wait, and then the predicate became false. I am guessing this sequence is a built in to allow a trigger to happen before the predicate becomes false, so thats cool. One thing I did think about last night was what would happen if this was left running on a mode change where lighting comes on or turns off, so I built another rule that cancels this one on certain mode changes.

Thanks again for everyones help!

A predicate rule must be true at the moment of triggering in order for the trigger event to "count," so this understanding sounds correct to me. One use for predicates is to capture specific state transitions, which in your case would be the specific transition from > 15 to <= 15. If you're looking for something like that, I'd say it's a good candidate for a predicate. (Not impossible to do without, but more difficult since you'd need to account for only caring about it the first time it crosses this value.)

1 Like