Rule machine question

I am trying to write a rule to alert me about a temp too high (ie freezer) but not get alerted everytime the temp chages (thus the isrunning variable), but also give me an alert if necessary every 30 minutes up to 6 of them.. and also alert me when temp is back to normal..
see the rule below it seems to be working and did stop alerts for 1/2 hour and then alerted me again when the delay expired in the initial invocation of the rule.. however I got an error in the logs (when the initial delay expired) and that is what i am asking about.

thanks in adavance, and thanks for such powerful tools.

it also looks like now after that error the rule itself got all hosed up.. see the if in the following screenhot it is checking some html now insetead of the boolean variable

on further analysis this appears to be an error in rule machine with looking at past logs where it has not stored the value of local variables.. the log for the exact same time stamp in the active log page looks ok.. when you go back and look at past events (for the same/event/time it looks hosed as above)

could multiple invocatons of the rule be trying to access the variable at the same time.. do i need something like a busy wait semaphore...

Seems like this would be much easier to do with hsm custom notification. Don't need all these variables and you can even set the frequency of notifications and methods to notify you.

Or even the built-in notifier app.

1 Like

I'd second the advice above to consider the Notifications app or HSM (the latter does a bit more than just notifications, creating an alert you'd need to clear/acknowledge in HSM, which you may or may not want). However, if you do want the extra customization a rule can provide, here are a few things I can think of:

  • Not sure what would be causing that "pop()" error in your first log, but I think I've seen that before if you have a "Cancel Delayed Actions" without any cancelable delayed actions. You don't seem to have either, but if you experimented with either at some point, that could be it.
  • The raw HTML in past logs is normal; they will format live but not past logs as of a recent firmware update, presumably to prevent rouge past log entries from ruining the format of the whole page (live are apparently rendered differently/more "safely")
  • Your "IF (Temperature < 16)" block is unlikely to be run much of the time, as the rule will not pause until that condition is met but rather evaluate it at the moment it reaches this line. While you undoubtedly know more about how your rule is supposed to flow than me, it seems like this would then not reset your "count" variable to 0, among other things you may not want.
  • I also don't see anything that will repeat the notification every 30 minutes

While you'd have to flesh out these examples a bit more to get all of what you want, if you want to continue using RM for this and get repeated notifications, I'd recommend starting by looking at one of these examples I often refer people to:

You may also be interested in the "Wait for event" action in RM, which will stop and wait for a specific event get created (i.e., attribute value to change) and then continue with the rule from that point, keeping in mind that any event that matches your trigger will start your actions over and also "cancel" the pending Wait. If you go with a rule that looks more like what you already have above, this may help.

I just use the Notifications app. Super easy and doesn’t trigger my hsm alerts. I tried it in hsm and it didn’t work properly for me.

1 Like

The notification app if youwant more than one notification spams you every time the temp changes so you get tons of messages. That is what im trying to avoid.

Ya none of those work. You see the trump keeps changing readily ie keeps either going up if freezer dies or defrosts or back down. So I tried the notification. App and got like 20 messages in 5 minutes. And a loop won't work as the end condition may never be met. And I want more than one notification in case I miss or forget about the first.

The final if should be hit after the delay of 30 minutes and if not boolean us reset and that works I get. A notice every 30 minutes.

I haven’t had that issue. I set it to only once in 30 minutes. I also didn’t set a low temp.

No tried that search for my other thread that only works on a SINGLE event. So if you get a temp is say 15 degrees it will.only notify you that many times. If you keep getting additional trigger events .ie temp is now 17 then 18 then 20 you get notifications again on each of those and that timee field doesn't prevent it.

Easy enough to make a virtual switch and rule to trigger when it goes above to turn on and when below turn off. That way you have a single event.

1 Like

I did not want a single event. Reread my description . I want more than one but not a ton like I got using the the notify rule. It works fine for a single event like a door left open.but not with a rapidly changing value like a temp.

Can’t you use a virtual switch as @lewis.heidrick suggested and just test against its state, every 1/2hr or whatever period you desire and use that to trigger your notifications ??

Yes, that's really where I was going with that.

Also, in my brief testing I couldn't replicate the spam notifications. I had 50ish temperature changes that I forced with device refreshes and had my notification interval set for 5 minutes and only got them every 5 minutes.

Here's the next notification.

And the next one

2 Likes

That’s been my experience as well.

1 Like

The only way I could see it spamming would be if you had a separate notification for multiple devices and they were notifying on multiple devices or you didn't set an interval.

The pop error is because your using delay without cancel when the rule can keep running. So each time the temperature changes your creating overlapping rules, because the 1st one hasn't completed due to the delay. You need to find a way to exit rule if the delay is happening. So at the beginning of the rule use a simple condition if

IF (freeze running) is true exit rule.

Thanks someone actually looking at the rule. Why would your
If with exit rule be sent different than my first if that basically says don't ho in the rule if it is running. Shouldn't that also immediately exit the rule because it fails and goes to the final enclosing end if?

ok here is my rule in notify app and here is a snap of my phone log you can see it is spaming me everytime the temp changes and not holding to the 30 minutes,. Somone in anotgher thread said that is the way it works.. rule is fired on every trigger event so a new temp reading re fires it. as long as you check you want repeats.

i will now try your way above with just a time limit