Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96121

How to Automate turning off lights with conditions?

$
0
0

@Daniel-san wrote:

Hi Guys, I created a few automations to automatically turn off the lights after X amount of time.
So far… they “work” but after living with these for a few days, I’ve noticed that my code is flawed.

here’s my code:

- alias: Master BedRoom Bathroom Auto Turn OFF lights
  trigger:
  - platform: state
    entity_id: light.master_bedroom_bathroom_lights
    from: 'off'
    to: 'on'
  action:
  - delay: 900
  - service: homeassistant.turn_off
    entity_id: light.master_bedroom_bathroom_lights
  id: 5602ac6d92c44a5a92c4545454b4454dkhfge code here

What I’ve been noticing is that when I trigger my automation by turning the light on, it will turn off in 15 minutes no matter what.

Problem is, if I manually turn off the light before the 15 minutes (say 13 minutes for example) and then turn the light back on, that original 15 minutes is still counting down and will turn the light off.

How can I avoid this?
How can I cancel the 15-minute delay if I manually turn the light off? or how can I restart the 15-minute delay if I turn the light on again?

I think I need to run scripts… but I don’t know how they work, (I have none today)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>