Updated Randminzed Vacation Lighting Script

This commit is contained in:
Jeffrey Stone 2022-01-19 07:07:44 -05:00
parent 907caa0a4a
commit 01322d2d3e
1 changed files with 59 additions and 12 deletions

View File

@ -102,28 +102,57 @@ randomize_vacation_lights:
entity_id: input_text.current_random_light entity_id: input_text.current_random_light
value: None value: None
mode: single mode: single
improved_randomize_vacation_lights:
alias: improved_randomize vacation lights
sequence:
- repeat:
until:
- condition: state
entity_id: sun.sun
state: 'above_horizon'
sequence:
- service: notify.mobile_app_jeffrey_ha_app
data:
message: Running Vacation Lights
- service: homeassistant.turn_on
data:
entity_id: '{{ expand(''group.vacation_lights'') | selectattr(''state'', ''eq'', ''off'') | map(attribute=''entity_id'') | list | random }}'
- delay:
minutes: '{{ range(1,3) | random | int }}'
- service: >
{% set service = ['homeassistant.turn_on', 'homeassisant.turn_off' ] | random %}
{{ service }}
data:
entity_id: >
{% if service == 'homeassistant.turn_on' %}
{{ expand('group.vacation_lights') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list | random }}
{% else %}
{{ expand('group.vacation_lights') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list | random }}
{% endif %}
- delay:
minutes: '{{ range(1,3) | random | int }}'
mode: single
randomize_vacation_lights_demo: randomize_vacation_lights_demo:
alias: demo - randomize vacation lights alias: demo - randomize vacation lights
sequence: sequence:
- repeat: - repeat:
count: '8' count: '8'
sequence: sequence:
- service: input_text.set_value
data:
entity_id: input_text.current_random_light
value: "{{ state_attr('group.livingroom','entity_id') | random }}"
- service: homeassistant.turn_on - service: homeassistant.turn_on
data: data:
entity_id: '{{ states(''input_text.current_random_light'') }}' entity_id: '{{ expand(''group.vacation_lights'') | selectattr(''state'', ''eq'', ''off'') | map(attribute=''entity_id'') | list | random }}'
- delay: - delay:
seconds: '{{ range(2,5) | random | int }}' seconds: '{{ range(2,5) | random | int }}'
- service: homeassistant.turn_off - service: >
{% set service = ['homeassistant.turn_on', 'homeassisant.turn_off' ] | random %}
{{ service }}
data: data:
entity_id: '{{ states(''input_text.current_random_light'') }}' entity_id: >
- service: input_text.set_value {% if service == 'homeassistant.turn_on' %}
data: {{ expand('group.vacation_lights') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list | random }}
entity_id: input_text.current_random_light {% else %}
value: None {{ expand('group.vacation_lights') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list | random }}
{% endif %}
mode: single mode: single
activate_arches_lamp: activate_arches_lamp:
alias: Activate Arches Lamp alias: Activate Arches Lamp
@ -155,4 +184,22 @@ dog_mode_lighting_on:
- service: scene.turn_on - service: scene.turn_on
entity_id: scene.diminished_kitchen_lighting entity_id: scene.diminished_kitchen_lighting
- service: scene.turn_on - service: scene.turn_on
entity_id: scene.security_kitchen_lighting entity_id: scene.security_kitchen_lighting
open_lr_curtains_lamp:
alias: Open Living Room Curtains
sequence:
- service: media_player.play_media
data:
media_content_id: open living room curtains
media_content_type: custom
entity_id: media_player.living_room_echo
mode: single
close_lr_curtains_lamp:
alias: Close Living Room Curtains
sequence:
- service: media_player.play_media
data:
media_content_id: close living room curtains
media_content_type: custom
entity_id: media_player.living_room_echo
mode: single