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

Turn off lights that has been on for hours

$
0
0

@jotadominguez wrote:

I am trying to set a automation to turn the lights that hass been on for more than 3 hours after 9pm until 8am.

This is because sometime the light in the living room stay on all night.

i have this but its not coded right

- alias: Auto Turn off Light at night
  initial_state: True
  trigger:
    platform: time_pattern
    hour: "/1"
  condition:
  - condition: time
    after: '21:00:00'
    before: '08:00:00'
  - condition: state
    entity_id: 'switch.luz_cuarto_entrada_nj'
    state: 'on'
    for:
      minutes: 30
  action:
    - service: homeassistant.turn_off
      entity_id: "switch.luz_cuarto_entrada_nj"

This code runs every hour and check if a switch has been on for 30 minutes, then turn it off.

The code works but the problem is that there are many light and switches to check, so i dont want to make an automation for every one of them.

Any ideas how to make this work?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



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