I have a spare Xiaomi vibration sensor which I’ve put into the back cushion of my couch. I’d like to somehow set it up that the “tilt” or “vibration” action translates into the system knowing I am sitting in the couch, so that when it is dark (using sun elevation), the lamp in the living room automatically turns on.
This is working OK so far, I just check for both states as a trigger and sun state as condition. The hard part is how to know when to turn off the lamp.
The sensor obviously does not continuously report vibrations or tilts as I’m not constantly moving in the couch. This means using the fact the sensor reports nothing is not possible as the lamp might turn off when I’m sitting (remarkably) still.
Currently I just turn it off after 5 min, which is far from optimal.
I was thinking of the number of reported vibrations/tilts to use as a counter and the condition to turn off the lamp would be the counter going to zero.
E.g.
Let’s say the first vibration gives counter = 5, every 5 minutes the counter decreases by 1, if another tilt or vibration happens, that means counter +1.
Is there a better way for this? Perhaps the gaussian binary sensor? Any ideas how to set that up with this usecase if that would be possible?
Create an automation that turns off the light if the vibration sensor is in an off state for at least 15 minutes. Put in a condition to check if the light is currently on in order to prevent the automation from needlessly sending a turn-off command.
If you know you can sit perfectly still for more than 15 minutes, adjust the time accordingly.
- alias: 'couch monitor'
trigger:
platform: state
entity_id: sensor.couch
to: 'off'
for: '00:15:00'
condition:
condition: state
entity_id: light.whatever
state: 'on'
action:
service: homeassistant.turn_off
entity_id: light.whatever
This vibration sensor is a zigbee device and is automatically discovered, right? In other words, you don’t have an entry for it in the configuration file, correct?