Time Triggered Rules Unreliable

I have a rule that should turn my living room lights (Philips Hue bulbs) off at a variable time (the time is set when the lights are turned on by separate rules). I have logging of events and triggers turned on for this rule. Around 1/3 of the time, the rule just doesn't fire. The variable time will pass, nothing happens. I have a similar rule for turning off my kitchen lights and it has the same problem. There is no obvious logic as to when they work, and when they don't (and I've ensured that other rules are not running triggered at the same time, just in case that was a problem).

What's odd, is that the rules to turn the lights on (at a specific time, rather than based on a variable) always work properly, it's only the ones that should trigger at a variable time that have a problem.

The rules themselves are pretty straightforward, but I don't think they are the problem, they just don't get triggered reliably! But, here is the rule for the living room:

Living Room Off Rule|690x464 .

Any ideas or suggestions?

From the outside looking in, I'd say that you really don't need to use variable time. Just triggers. I've never used anything like this in my rules and have rules that depend on something else turning on or off. Like my living room table dims if the overhead light turns on and brightens when it turns off. IMHO I'd eliminate the variable time and use the other lights as triggers for the rule.

light A becomes changed

if light A is on
then turn on light b and C
Cancel delayed actions
if light
if light A turns off
then turn off light B and C
delay 10 seconds cancelable

I know that it's not a reorganization of your entire rule, but I think I've given you a good enough idea on how I'd remedy it. I think you could also possibly control some of this in simple automation. Just a humble thought. I'm unsure of your specific use case as to why you chose to use the variable time, but I feel that it might not be necessary unless the bigger picture requires it. I don't know what your bigger picture is. I can only speculate.

Thanks for the response.

From a perspective of triggering, for my purpose it really does have to be a time, there is no physical trigger available. E.g. on a weekday, I want the living room lights to turn off at 8am as that is when my wife leaves for work.

It needs to be a variable time, because there are other sensors at play. For example if the living room is still occupied (e.g. its a holiday) and motion is detected, keep the lights on until 5 minutes after motion was last detected. The only way I could see to implement that is as shown in the rule - if the room is occupied, increment the time by 5 minutes so the rule runs again. If the room has been occupied in the last 5 minutes, increment the time. I also want to add additional logic so that if the room is occupied, but it is bright outside, turn the lights off anyway, as they are not needed.

The general idea is, other than exceptional circumstances, you never have to mess with the lights, they look after themselves, based on time, motion and light level. Obviously simple automation can't handle that.

The other reason I ditched simple automation, was that I have another variable that sets the colour temperature I want for the hue lights depending on the time of day. The rule that turns the lights on automatically uses this variable to set them to the right colour immediately. Again, simple automation couldn't do that.

Finally, I deleted all the simple automation events I had, even the ones that I didn't want to add additional logic to, as I was finding crosstalk between simple automation and the rule machine (e.g. for some bizarre reason I couldn't even fathom, simple automation would turn my kitchen lights off, which would trigger the living room lights to come on, even though there was absolutely nothing in common between the two). I figured I'd switch to all rules, even for simple tasks and just ditch simple automation.

As I said, what's weird is that rules using a specific time work flawlessly. Rules that use a variable time work fine (even the rule running again after the time is iterated works fine), but they frequently just aren't triggered at all (or, occasionally, are triggered at the wrong time).

I can appreciate your use case and respect it. I wish I could help with it, but the big picture is not drawing out for me, and is not something that I've needed. Perhaps maybe @bravenel could weigh in on this for us and offer some input here?

I wouldn't use variable time to do this. I guess to see how best to do it, I'd need to know what the full use case is for these lights to be turned on and off. That would be more useful than seeing how you are attempting to do it. Can you describe everything that controls these lights?

1 Like

IMHO That seems like a lot of work. My lights are based on motion and lux. If there's motion, they simply turn on if it's dark enough in the room. There are so many other factors like cloud cover and curtains that will affect whether the lights need to be on or not. I like to write my rules loosely for this reason. They seem to turn on and off when they should and writing a rule to control the color or temperature of a light could easily be based more loosely to achieve the same effect. I just feel like there's too much room for error to have a variable time rule. But, I don't understand your use case. I'm looking forward to reading about it and what Bruce's input will be. So, I'll be following closely. I'm definitely not criticizing, but am very interested in the logic around your automation.

Hi Paul,

I don't have an HE yet (patiently waiting) so I'm not sure if this feature is available but it sounds like a watchdog timer situation. No motions starts the timer then each time motion is detected it resets the timer.

Without knowing the syntax yet something like...

If no motion then start delay timer (to turn off lights)
If delay timer done then turn off lights.
If motion then reset timer

This will not rely directly on any actual time of day variables.

I think I get what you are doing and I'm pretty sure a wait for condition would be able to replace the setting of the time variable.

It would be something like this

Trigger 7:55AM
Wait for condtion Motion inactive
if lights on then
speak "Turning lights off" delay 5:00
Turn lights off delay 5:00
end if
If variable true
Then turn off other lights delay 5:00