Rule Triggering When It Shouldn't

I have a simple rule that monitors battery level in several devices. It is set up to send me a message if any of the devices battery levels drop below 30. It has been fine for some time. All of a sudden It is triggering even at higher levels. I check the device events and there is no indication of a lower level. Here is the rule and the rule events. You can see where it is being triggered by the wrong value.

My initial thought is, anytime the device is not reporting, it is technically <30. At some point anyone of those batteries is going to hit 30. I doubt they would skip 30, so why don’t you change it to =30?

Looking at your screenshot, you have a device (actually two) <30. Therefore, the rule will trigger on any battery report as long as you have one item satisfying the trigger.
https://community.hubitat.com/t/is-it-me-or-is-it-rule-machine-battery-level-isnt-doing-what-i-expected/19272

2 Likes

Have you thought about using HSM.
I use it for my battery reports and it seems to be working fine.


3 Likes

Good catch. I looked at that myself and missed those two that are reporting at 24% on the first glance. I'm sure the OP did too. :flushed:

1 Like

(Not my Rule, but...) I must be missing something here: if a device doesn't report, it should still keep its last battery level attribute as it was during the last report. If it doesn't report battery level at all, it shouldn't implement this capability and therefore shouldn't be a device selectable here, but I guess I don't know what would happen if you somehow managed to anyway. Otherwise, if it falls off your network, I think the previous would apply. I also rarely see battery levels fall in increments of 1--it's often 10 to 33 percent (yep :scream:) or so at a time, especially with lithium batteries where the beginning to middle stages of battery life are harder to estimate. I wouldn't be surprised if some did, indeed, skip 30, but I guess that depends on your devices.

I think the issue here is what was pointed out above, which I guess you see now too: two of the devices are indeed below 30%. I know for sure the rule will continue to trigger any time the same devices continue to report values at or below 30 (the "becomes" phrasing is misleading since this trigger also covers "is still"). What I don't know is if one of the trigger devices is under 30% and another one is over (so it alone wouldn't trigger), would an "over 30" device changing still fire the trigger because there is an "under 30" device even though the "under 30" device didn't change? I wouldn't think so, but that does look like what's happening based on the events screenshot. (EDIT: This guess is indeed correct; see below. A bunch of devices combined into a single trigger will fire the trigger if any [or all, if specified] meet the criteria whenever any change; this differentiates a "combined" trigger with many devices from a bunch of separate triggers for each device, i.e., those strung together with OR).

EDIT: I have to revert my previous statement.....

As long as one of the conditions of a single device in a single trigger definition matches the condition the rule is triggered.

Like here:


vDimmer_2 is below 30, so when vDimmer_1 fires (any value), the rule will be executed

Here is a different definition (two trigger events):


Each dimmer got it's own trigger definition. In this case it will only get fired when the value of that dimmer that is firing is below 30

Makes sense?

3 Likes

I initially thought the same as your un-edited post but then looked at what was happening and assumed it must have worked the way you discovered (in the first scenario) instead. Thanks for testing to verify! I didn't feel like setting anything up to try it with. :slight_smile:

I also completely forgot that the second option, using multiple (ORed) triggers, was something the original poster could do to solve this problem. It's a heck of a lot more clicking (compounded by the fact that you have to specify "30" for each one), but it would fix the issue. I imagine HSM or a third-party app like Device Watchdog would make this a lot easier, though.

Nice work!

Yes, I was completely off in my head originally.... Thank god for virtual devices.....

Yes, it is a pain to maintain in that specific scenario, that's why I use HSM for that, however, for other scenarios where you only have two or three triggers it could be very beneficial to know the difference

Thanks for all the replies. I did't realize it would trigger everytime a battery updated. I just assumed it would only trigger when the value went below 30.

Gonna try the HSM battery monitor. A little puzzled there as to the frequency of the notifications. There is the option for only once a day, but does that mean it will tell me every day that a particular battery is low? I only want 1 notification of a given battery. It's up to me to remember I got it.

HSM is going to send you an alert every time the value changes and is below your threshold.
E.g. on the same day, the battery for one devices goes first to 20% and then to 19%, you will get two notifications.

If you turn on "only once per day", you would only get one notification (the first one)

On the next day, you will get another notification if the device reports a value below your threshold

Yes...it is not clear from the documentation but it is a state trigger (being less than 30) rather than a threshold trigger (becoming less than 30).

There is a notifier app that wil do this as well, but it will also trigger on every time a battery reports in <30, not just the first time. My notifications discovered this a week ago!

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