Hey guys, I have an Aqara vibration sensor on my outdoor trash can that gets picked up by our removal service weekly. The plan was to toggle a home assistant switch when vibration is detected so that I know whether the trash was taken out or if its still inside. However, I only want to detect vibrations that are longer than, say, 30 seconds, since that is about how long it takes for me to bring the trash down the driveway. Any other vibrations that are just a few seconds will happen when I open the trash lid to put a bag inside of it.
On the home assistant trigger, I had it set as below, with the thought that this was looking for the duration of the vibration. However, this didn’t work, and any vibration immediately triggers the automation regardless if it is 30 seconds or not:
platform: state
entity_id: binary_sensor.trash_vibration_sensor_3018
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
What is the best way to go about doing this kind of automation properly with minimizing false positives? I’m wondering if setting up a “wait for trigger” event would be better, although I’ve never messed around with that before.
Unfortunately, since the vibration duration doesn’t register, this doesn’t seem to work. The sensor will only register if there is a vibration or not, it doesn’t actually note the duration. I’ve tried to do something similar to:
Detect vibration
Delay 20 seconds
Wait for trigger of detecting vibration again. If so, toggle the switch.
However, this doesn’t seem to work either since if detects vibration in step 1 for just a second, it still waits the 20 seconds for step 2, but step 3 never happens. So it could be days later, but when any vibration happens again, it will toggle the switch. I need to be able to timeout the “wait for trigger” step 3 after a few minutes I think.