What do I not get about the rule machine?

I do not understand why the following is happening with the below pictured rule.

When I wake up I find my "chill" lamps on that are meant for evening use.
For instance this morning i see in the logs that my scene_chill was activated 11 times between 6:56 and 8:01. Preceding every activation the illumination sensor gave a lux value update. At 6.56 there was the first value update above 0 (=1) after giving 0 all night. At 8.01 the illumination value was 147 which was the last illumination value change before going above 150.

Why does the trigger not only fire when the illumination drops from above 150 to below 150? Why does it triggers with every illumination change below 150?

Why does it trigger the scene anyway at this time of day with the condition being between 16:00 and 22:00 (and with the correct time zone setting)? BTW the app added the first illumination condition automatically.

Note that I have no other rule or automation that triggers scene_chill.
I had the logging off for the shades so I guess that is the reason this did not also show with all scene triggers in the logging

What do I not get about this (simplistic) RL syntax?

Using illumination as a trigger is tricky. Every time a new illumination value is produced by your device the rule evaluates the value and triggers if it is less than 150. It doesn't work in the way you are thinking in that it should only trigger when the actual luminance threshold is reached.

You have conditions there. But, those conditions aren't really doing anything until you add them with some kind of conditional statement (If, Then). Basically, the conditions in the Manage or Create conditions do not get evaluated unless you call them out. They are basically just there for you to use if you want them.

In your actions to run section, you need to add a conditional action "If Illuminance of Lux is <= 150" and then add an "AND" and then add the second time condition. Do this as an "insert before" and place it before the "Lower shades" action. Lastly, add an "End IF" at the end of the action section. You can just "add action" in order to place it at the end.

Since they are already there in the manage conditions, you would be able to just select them a parameter instead of creating a new condition.

Your actions section should look something like this:

1 Like

Thanks both for your help. If I understand correct this would bring the result I intended ...

Should I worry about the fact that still the illumination trigger will fire with every change between 0-150?
I use this sensor and similar comparisons for multiple rules and this sensor illumination changes and follow up rule triggers are numerously reported -in bursts- in the logs.
Maybe use a smarter "when dark" rule/variable that filters all the changes except the transition? Any suggestions?

Maybe add another condition that would restrict the rule from running again?
For example you might add something like if shades are up, or if that scene chill is activated there might be a light you could set as a condition?

Have you read through the hub documentation pages on rule machine?

https://docs.hubitat.com/index.php?title=Rule-4.0

https://docs.hubitat.com/index.php?title=Rule_Machine

As noted above, you initially added conditions but did not include them in the actions, hence your rule not performing as intended after the trigger occurred.

It looks like you've taken care of that part so far. To restrict your rule to occur only once after illuminance goes below your threshold (rather than every time the sensor reports illuminance below your threshold), you have a few options. Use of private boolean is probably a good one. You can find some more details on how to restrict actions in Rule 4.0 (the current version of Rule Machine) in this thread:

Edit: also, you don't really need the illuminance conditional statement in the actions, because the rule is triggered by illuminance <150; in other words, that condition is already implied every time the rule runs.

2 Likes

Not sure how often illuminance changes as I do not have one. But, you might possibly change the trigger to illuminance changes and add a private boolean set initially to false.

Then it could possibly look something like:


/Trigger/
Illuminance of Lux changes

/Actions/
If blnYourBoolean is false then

     If illumance <= 150 and Time between start and stop times then
            Set blnYourBoolean True 
            Lower Shades
            Activate Scenes
      End If

Else

      If Illuminance > 150 
      Or NOT time between begin and end times then
            Set blnYourBoolean False  */ Needed to reset from true to false/*
      End If

End If

Note: This would lower your shades if you had raised them back and the illuminance falls again within the times specified. You could also add a check for if the shades had already been lowered.

1 Like

Thanks for the suggestions. I will give it a try.

P.S. I work in industrial automation and program PLC's for a living. I think that spoiled me for RM :thinking:

I will give the following a try:
A rule to set/reset "dark" which I made a global variable because I can use it with more rules e.g. with opening of shades (if it works as expected :wink:


and 1 simple rule to trigger the closing of shades and the scene (hopefully this only triggers once on the false/true transition).
rule4

If you aren't determined to figure out/use RM, you should look at Event Engine...community app that allows for more complex automations than Simple Automations or the Motion automation app, including multiple triggers (called "Conditions in Event Engine), triggering actions using all and any, and in particular in your situation, it has a built in option to react to a Lux change based on a rolling average. Worth a look.

1 Like

Thanks. I have not looked at the Event Machine yet but I actually use several motion apps (but don't see that as an option for the "start of the evening" detection ).

Event Engine supports a very wide range of what are called "triggers" in RM, Event Engine calls them "Conditions." You can layer a time/days condition on top of them.


image

image

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.

Download the Hubitat app