Here’s my automation.
- alias: motion_detection1
initial_state: True
hide_entity: False
trigger:
- platform: mqtt
topic: "home/sensors/ESP8266_1/motion"
payload: 'on'
condition:
condition: or
conditions:
- condition: template
value_template: "{% if (states.sensor.esp8266_1_light.state | float < states.input_slider.motion_light1.state | int)
or is_state('input_slider.motion_light1', '0.0') %}true{% endif %}"
- condition: state
entity_id: script.timer_off1
state: 'on'
action:
- service: homeassistant.turn_on
entity_id: script.timed_switch1
it calls a script, and this script calls a script to reset (from the examples page)
timed_switch1:
sequence:
# Cancel ev. old timers
- service: script.turn_off
entity_id: script.timer_off1
# Set new timer
- service: script.turn_on
entity_id: script.timer_off1
- condition: state
entity_id: switch.milight3
state: 'off'
- service: switch.turn_on
entity_id: switch.milight3
timer_off1:
sequence:
- delay: '00:00:{{ states.input_slider.motion_timer1.state | int }}'
- service: switch.turn_off
entity_id: switch.milight3