Advice: How to configure an action if a button Is NOT pressed in a given time window

Is there a way to send a notification or trigger an action if a button is NOT pressed in a certain time window. Any help would be appreciated.

Yes, but can you describe in more details what you're looking for? When or how do you want this window to start, for example?

Thank you for your quick response. I take medication that needs to be taken within a 30 minute window everyday. I use Aqara mini buttons and I would like to take the medication and press that button. If it is not pressed by 8am I would like a notification in the app and trigger a light to flash or change color. I am familiar with the setup for everything but the condition where the button is not pressed.

Here is one way to do it:

How this works:

  • I created a local variable called "l_device".
  • I set the rule to run at 4 AM every day. Adjust as necessary. You want it to run earlier than you would ever take the medication.
  • When the rule runs, it starts waiting for a certain button to be pressed with a timeout of 4 hours (so in my example it will timeout at 8 AM... adjust the duration based on your start time so the timeout happens at 8 AM)
  • When the 'wait' exits, the built-in %device% variable gets set to either the button name (if the button was pressed) or the word "timeout" (if the timeout occurred). I set "l_device" to the value of %device%
  • Then using a conditional... if "l_device" = timeout, we know the button was not pressed before 8 AM. Stick in whatever notification actions are needed between the "IF" and "END IF" where I have the log action.
  • If the conditional is false, nothing happens and the rule runs again at 4 AM tomorrow.

In the screenshot, I pressed my "Test Button" so you can see the %device% and %l_device% variables are equal to "Test Button"

2 Likes

I would have never figured that out. I greatly appreciate you taking the time to do this.