Rule execution delay

I just started playing with the rule engine. I was wanting to move some of my simpler webcore pistons into Sharptools however I am getting prolonged delays, anywhere from 10-30 seconds, before execution.

Example.
Triggers
Motion sensor 1 or 2 changes to active
Motion sensor 1 or 2 changes to inactive

Flow
If any motion sensor is active
If light is off
Then turn on
Set variable true

If all motion sensors are inactive for 3 mins and variable is true
If light is on
Then turn off

If light switch changes to off
Then set variable false

Any help is greatly appreciated.

Hi @Terri, if you can post the Rule ID (the URL when you are editing this rule), I’d be more than happy to take a look of the exact rule setup and let you know what I find. I never had this prolonged delay so I’d be curious to know the details.

Meanwhile, I think the posted rule logic may not work as you desired for turning off the lights. When either of the motion changed to inactive, this rule will be triggered, but the if condition in the flow of checking if all motion sensors have stayed inactive for 3 minutes will never be satisfied because one of the motion sensors was just changed to inactive within milliseconds.

See below for a quick rule example that I moved the “motion stayed inactive for 3 minutes” from if condition in the flow to the triggers section, and used the context variable to check the triggering event’s value, instead of having to query the motion sensor’s state. (Choose Variables → Context Variables → Event → Location/Device Event and then value.)

And it’s likely you don’t have to check the light’s on/off state before sending the command. Some lights simply ignore the on/off command if the lights are already at on/off state. You can do a quick test to send an “on” command to the light which is already on to find out. If so, you don’t need to query the lights’ state in the if condition, but just send out the desired on/off command.

Feel free to let me know if any questions.

Here are two rules that are having the delays.
I edited the light with motion to include the 3 mins in the flow as you suggested.

I only have to check the switch status like this with 2 lights because they are connected by Bond so it doesn’t check the switch status before sending the command.

Light with motion
https://sharptools.io/rule/edit/aV92NaSfVESbzpA6xvvr

Meeting button
https://sharptools.io/rule/edit/WSOXTR8xJoEnQ9G9GVR0

I’m not opposed to using the context variable but I’m not sure how to add the last bit of my logic. The programmatic is used so that if I manually turn the switch off and then on, the light doesn’t turn off when motion clears. (At least that is how it works in Webcore).

Thanks for your help!

Thanks for clarifying the rule needs. Please note that the context variable used in my suggestion is just to remove the need of checking individual motion sensor’s state in the IF Conditions in the Flow section, because it can take few hundred milliseconds to query each device’s state, so using the context variable can speed up the rule execution in this case.

See below for the updated Rule for Light with Motion. I used variable $isProgramatic to determine if it should turn the light off as you had in your original rule and replaced the device state check in the IF conditions with context variable .

Here the example rule for your Meeting button rule. Your original rule should technically work and I am surprised it had this prolonged delay because it is a pretty simple (less IF conditions) rule. How much delay did you experience with this rule? And does it always perform like that? The other idea is to add a notification as the first action in the Flow to help understand where the delay came from.

Let me know if this helps.

Yes, it is always this delayed.

I have noticed that most rules, even just turning a light on/off have upto a 7 second delay before the command is sent (according to the green command prompt) using a Fire HD 8 10th gen.

I will try the changes you suggested and let you know if there’s any difference.

Can you please take a video of the simple rule execution - one light on, turn the other light on and send it to support@sharptools.io? And let me know the rule id. This certainly doesn’t sound right. My bath room light rule turns the light on when a motion is detected, and the light is turned on in a second when I walk in.

I am happy to report that after deleting my rules and recreating 2ith your suggestions they are firing with minimal delay! Thank you for your help

2 Likes