Trigger notification only x minutes


#1

I have a piston that text’s me under certain circumstances. It triggers primarily by a change in temperature from a sensor. I would like to get a notification no more often than every 15 minutes. However the temperature can sometimes change every few minutes, and if I ignore it for a bit (don’t open the windows) it can get annoying.

I’ve thought of changing to a timer (run every 15 minutes, then an if statement inside of that) but I believe there is a more elegant solution.


#2

Without putting much thought into it, that’s how I would do it.


#3

You can use a local variable to keep track of the last time you sent a message and skip sending if one was recently sent.

if( want to send )
  if( now > addMinutes( last_sent, 15 )
    send SMS
    last_sent = $now

You need to manually initialize last_sent before the piston will work