I am testing hassio with simulated mqtt motion sensor. I have typical issue.
I wanted to turn on switch for 1 min where there is a motion.
When I enabled binary sensor using developer tools, automation gets triggered. Also I can see motion detected in UI.
When I sent mqtt_publish via command line I only see motion detection on UI, automation not working
mosquitto_pub -h 192.168.1.18 -t a/b/c -m ON
…
Here is my automation
alias: Turn on kitchen light when there is movement
trigger:
platform: state
entity_id: binary_sensor.motion
to: ‘ON’
action:
service: switch.turn_on
entity_id: switch.door
alias: Turn off kitchen light 10 minutes after last movement
trigger:
platform: state
entity_id: binary_sensor.motion
to: ‘OFF’
for:
minutes: 1
action:
service: switch.turn_off
entity_id: switch.door
Action
- turn on light
- delay 10 min
- turn off light
The little problem is that the light will shut off regardless if there is motion or not after 10 min. It will turn back on after motion occurs again. If you want to prevent that, I think you will need a script .