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

Help with automation simulation

$
0
0

@Makis wrote:

Hi
I would like to simulate presence every night between 00:30 - to 06:00 in the night
but each time to turn on 1 light
after xx minutes I would like to turn off the light that previous turned on and turn on the 2nd light of my group (I have 5 lights in my group)

I found a piece of code to start with and I change it a little
Can someone confirm that it will work or an idea how to implement this

#############################################################################
## Turn on/off indoor lights randomly 
#############################################################################
- id: Night_Lights
  alias: Night_Lights
  initial_state: True
  hide_entity: False

  trigger:
    - platform: time_pattern
      minutes: '/10'
    

    - condition: time
      after: '00:30:00'
      before: '05:50:00'
    

  action:
    - delay: "00:{{ '{:02}'.format(range(0, 30) | random | int) }}:00"
    #- delay: "00:00:{{ '{:02}'.format(range(0, 10) | random | int) }}"
    - service: homeassistant.toggle
      data_template:
        entity_id: "{{ state_attr('group.night_simulation','entity_id') | random }}"

################################################################
## Turn off indoor lights randomly between 
################################################################
- id: Turn off all lights
  alias: Turn off all lights
  initial_state: True
  hide_entity: False

  trigger:
    - platform: time
      minutes: '/15'
      
  - condition: time
      after: '00:40:00'
      before: '06:00:00'

  action:
    - delay: '00:{{ range(10,18) | random | int }}:00'
    - service: homeassistant.turn_off
      entity_id: group.night_simulation

Posts: 15

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>