@WCmore: Thanks for this!
I woke in the middle of last night with an idea. What I presented to you was only a quarter of what Iâm doing. My piston is a Dryer piston based on acceleration from a ST multisensor. There are four states: off, warmup, standby, active. Off is default.
On acceleration event, piston goes to warmup status.
Warmup is when 7+ acceleration events occur within a short span (3 minutes). This represents the user opening the dryer, loading it, closing it, setting the dial, and finally turning it on. Each new Acceleration event resets the timer to three minutes. If the event counter never gets past 7 and three minutes pass since the last event, then it was a false alarm and status goes to Off.
(Iâve had lightning strikes set off that sensor, even though the thing is in the basement!)
If eight or more events occur, we move to Standby status. A 15 minute counter begins. Reasoning: a flurry of activity in the region of the dryer could have been non-dryer activity! It could have been loading the washing machine and using the dryer as a table. It could have been prepping beach gear, which we keep in that area. Etc. So we need to validate that indeed, the dryer is being used. (Iâm hoping to eventually use various values from the accelerometer to determine whether itâs a person, or the dryer itself, causing the acceleration.)
If we get a confirmation event, we move to Active status and the timer gets reset to 15 minutes.
From here, each new accelerometer event resets the timer to 15 minutes while remaining in Active status. When the timer finally runs out, an announcement happens on my Echo devices and the status goes to Off.
My thought in the middle of the night was that really, the whole thing is a timer - and all the above after the initial activating event could be encompassed in a Do While (timer is ticking) loop, with events within the loop occasionally resetting the number of seconds til the loop reaches zero. In other words, I DO want events to affect the timer. But youâve given me a new approach. Iâm gonna play with this and see where it goes. I think Iâd need two separate timers, a 3 minute and a 15 minute. Events would re-trigger the start of the timer.