As I mentioned in my post here, not all sensors report ‘OFF’
Hence you cannot use trigger.to_state.state
I guess that would make it something like this:
alias: Light on Motion
description: Off when no motion for 3 mins
trigger:
- alias: When motion detected [Pir] was trigged by MQTT
platform: mqtt
topic: stat/Tas_Ten_PIR/MOTION
payload: "ON"
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.tasseven_tasmota_seven
- delay:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
- service: switch.turn_off
data: {}
target:
entity_id: switch.tasseven_tasmota_seven
mode: restart
Note that this automation is in ‘restart’ mode, as you want to reset the timer every time the automation is triggered