Restricting a trigger to run only once per mode change?


#1

I actually have 2 questions. 1, is there a way to run a piston only once per mode change (as the title suggests) and 2, how do the “only on certain days” restrictions work?

I bought a Xiaomi Robot Vacuum and I’m hacking together a way to automate it using sharptools and Tasker. I’ve created a virtual switch that sharptools will react to telling Tasker to run a task that will speak the words “Alexa, turn on/off the vacuum”. Pretty shitty but it will work. I’m trying to get the vacuum to run any time we leave the house, this is pretty easy, but also at night (on the weekends only, this is where my second question comes in). I currently have a piston that turns lights off after inactivity of 30 minutes at night, I’d like to turn the vacuum on at this time too. However, sometimes we’ll go back downstairs and the motion will kick up again, thus, triggering the piston again 30 after inactivity. I don’t want the vacuum to trigger again so I’m wondering if there is a way to restrict the vacuum part of the piston from triggering more than one time after my home has changed to “night” mode (sunset to sunrise)? Secondly, I really only want this to happen on the weekends, so, Friday and Saturday night, but sometimes activity won’t settle down til after midnight so it may be Sunday morning, any ideas what the best way to accomplish this would be?

Thank you all so much for your help!


#2

Completely untested… maybe you can build off of this. lastDay variable is to restrict the switch to turn on only once a day. Also the second IF might need a time restriction for night time run only.


#3

I’m picking up what you’re putting down. The only issue I see with this is if the piston fires before midnight then again after midnight. But I could build on this somehow and create a variable that is written when the mode changes. Thank you for bringing me to the light.


#4

If you’re referring to the second IF, you can just add another boolean variable that sets to true when the vac runs, follow it with a timer that doesn’t cancel to set it to false after a given number of mins or hours.


#5

In this thread (#4) I show how to use Time as a lockout so that you can restrict how often a piston runs. The example uses minutes, but the same thing exists for hours and days as well.