Hello again!
Just tested the automation at home and can say that it works perfectly!
Here it is:
- alias: Luzes da casa - Quarto
trigger:
platform: state
entity_id: binary_sensor.movimento_quarto
to: 'on'
condition:
condition: state
entity_id: light.luzes_principais_quarto
state: 'off'
action:
- service: light.turn_on
entity_id: light.luzes_principais_quarto
- delay: 00:00:05
- wait_template: "{{ ((is_state('light.luzes_principais_quarto' , 'off')) or ((((as_timestamp(strptime(states.sensor.date__time.state, '%Y-%m-%d, %H:%M')) - as_timestamp(states.binary_sensor.movimento_quarto.last_updated) ) / 60) | int) >= states.input_number.timmer_quarto.state | int and is_state('binary_sensor.movimento_quarto' , 'off'))) }}"
- condition: state
entity_id: light.luzes_principais_quarto
state: 'on'
- service: light.turn_off
entity_id: light.luzes_principais_quarto
Oddly, I had to put a delay: 00:00:05
just before the wait_template, if not, the automation hags just like before.
I’ve created a few input_number sliders so I can set the minutes I want the lights to go off:
Now I just need to discover how to set these sliders to be only these number available “1,2,3,4,5,10,20,30”, so it could be a bit smaller a easier to set.
Thanks a lot again mate! Have a great one!