[Resolved] Conditional triggers based on time since last event dont seem to work

I was trying to avoid using private booleans to prevent a rule from triggering while the actions are already running.

But creating a simple conditional trigger based on time since last motion event does not seems to act the way I would expect. So I have gone back to the boolean.

Should a simple conditional trigger based on time since last motion active work?

Are there any other best practices for keeping events from stacking?


Conclusion: The RuleMachine time of last device event cannot be the device that triggered the event. Because that time is always zero.

RuleMachine could use enhancements regarding date-time variables. The concept of now() and date-time math (deltas) is needed.

Alternatively, there could be private virtual devices inside a rule. Like defining a variable.

Or the "Actions" for a rule could become a device to turn on or off.

Or "Time Since Last Event" could point to a variable instead of a only devices.

Can you post a screenshot of your rule with the conditional trigger? And logs indicating that it didn't work as anticipated?

3 Likes

There are probably two questions worth answering up front...

  1. Is there a reason you have taken the view that:
  1. Do you have any details on the rule you are constructing?
3 Likes

I will have to set it back up that way. I will do that and reply with a screenshot

2 Likes

To debug this potential issue, please do the following:

  1. When you construct your rule, turn on logging for Events, Triggers, and Actions.
  2. Post a screenshot of your rule.
  3. Let the rule run, and then post a screenshot of the logs from the rule running.

I wanted to avoid using private booleans because they are not "self maintaining". I dont want to be in the position where an interruption will leave a boolean in a false state where the rule will never run. I have buried "set everything to true" statements in periodic rules to sweep these, but its a kludge.

Ok, thx.

1 Like

At post 10pm I can't argue with any heft... So that seems like a good approach to me. Plus, regardless of the time, I can agree with the fact that managing a boolean can be problematic. The more experienced (and awake) users may offer whether there is an option to adjust a private boolean on bootup... ?

I use PBs for stuff that has a relatively short duration (bath fan during shower, dishwasher running, etc) -- that way, the risk of its T/F status somehow getting messed up is low.

I have a house-keeping rule that runs at ~3am nightly that refreshes/resets a bunch of devices and it also ensures all of my PBs = True.

WRT conditional triggers vs required expressions, I decide on that by considering the balance of how often will the trigger event happen overall and how many of those occurences do I want to trigger this rule?

4 Likes

The use of PB's is not an all or nothing thing in terms or correctness, as I have found out in recent weeks, you do need to "manage" them in all circumstances where you update stuff (for me handling opening of blinds in the morning). So there is no "correct" option, just one that can be managed more effectively. I am stilll in favour of PB's in many circumstances, but they need some consideration, like any option.

2 Likes

Ok, I see it. The device update time is set when I trigger the device. But of course by the time my rule sees it, the time since the last event is zero (it just happened).

I understand this issue. I am going to try a virtual device that only my rule uses.

I cannot do what I wanted. The time since the last event becomes zero (since I just triggered it) so the event timer is zeroed before the rule fires.

If you want additional help, you're going to have to provide more information about what exactly you're trying to do.

Posting a screenshot of the rule you had in place may be a helpful aid in that.

4 Likes

The time is updated instantaneously when the motion device sees me. So the time since it was last activated becomes zero when the rule sees the event..

time since last event cant be -that- event. It has to be some other event.

They really need a 'time since rule was last trigger/run' condition.

I am putting a virtual button in. I will trigger that in my actions. and that will set
my timer.

The virtual button is working as expected. I virtually press the button inside the rule and that event can be used in the "time since last event " conditional trigger.