Compare commits

..

6 Commits

3 changed files with 156 additions and 55 deletions

View File

@ -3217,26 +3217,6 @@
adapt_brightness: '{{ is_state(''switch.adaptive_lighting_adapt_brightness_master_bedroom'',''on'')
}}'
mode: restart
- id: '1697475527093'
alias: Lighting Effects Concept
description: ''
trigger:
- platform: state
entity_id:
- input_boolean.toggle_testing
from: 'off'
to: 'on'
condition: []
action:
- event: lightfx
event_data:
basement: true
first_floor: true
color: red
divide: half
duration: 10
lifx: move
mode: restart
- id: '1697819133179'
alias: Give Me Darkness
description: Automatically trigger Give Me Darkness if it has not already happened

View File

@ -980,7 +980,33 @@ script:
- critical
variables:
voice: "{{ states('input_select.jarvis_voice') }}"
groupname: >-
{% if who == 'kids_bedrooms' %}
kids_bedroom_speakers
{% elif who == 'all_bedrooms' %}
all_bedroom_speakers
{% elif who == 'basement' and is_state('input_boolean.studio_quiet','on') %}
alexa_no_basement
{% else %}
{{ who }}
{% endif %}
sequence:
- service: script.get_room_speakers
data:
room: "{{ who }}"
response_variable: "get_room_speakers"
- choose:
- conditions: "{{ who in ['everywhere','Everywhere'] }}"
sequence:
- service: script.get_all_speakers
response_variable: "get_all_speakers"
- conditions: "{{ get_room_speakers.jarvis_tts == 'group' }}"
sequence:
- service: script.get_group_speakers
data:
group: "{{ who }}"
response_variable: "get_group_speakers"
# Need to figure out whether to do this part here, or in alexa/jarvis voice scripts, or both
- service: mqtt.publish
data:
topic: 'house/polly/lastmsg'
@ -1024,44 +1050,13 @@ script:
- service: >-
{% if voice == 'nabu' %}
script.nabu_voice
{% elif who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
script.alexa_voice
{% elif who in ['kallen_bedroom','Kallen Bedroom'] %}
{% if is_state('input_boolean.kallen_sleeping','on') and type not in ['critical','Critical'] %}
{% elif get_room_services.jarvis_tts in ['group','alexa'] %}
script.alexa_voice
{% else %}
script.jarvis_voice
{% endif %}
{% elif who in ['emma_bedroom','Emma Bedroom'] %}
{% if is_state('input_boolean.emma_sleeping','on') and type not in ['critical','Critical'] %}
script.alexa_voice
{% else %}
script.jarvis_voice
{% endif %}
{% elif who in ['master_bedroom','master_bedroom_echo_dot','media_player.master_bedroom_echo_dot','Master Bedroom Echo Dot','Master Bedroom'] %}
script.alexa_voice
{% elif who in ['kids_bedrooms','Kids Bedrooms'] %}
script.jarvis_voice
{% elif who in ['all_bedrooms','All Bedrooms'] %}
script.alexa_voice
{% elif who in ['Basement','basement','basement_echo_dot','media_player.basement_echo_dot','Basement Echo Dot'] %}
script.alexa_voice
{% elif who in ['Basement Google','basement_google'] %}
{% if is_state('input_boolean.studio_quiet','on') %}
script.alexa_voice
{% else %}
script.jarvis_voice
{% endif %}
{% elif who in ['Common Areas','common','common_areas'] %}
script.alexa_voice
{% elif who in ['alexa_everywhere','Alexa Everywhere'] %}
script.alexa_voice
{% elif who in ['Everywhere','everywhere'] %}
script.alexa_voice
{% else %}
script.alexa_voice
{% endif %}
data:
# Work on where this redirect logic should go
who: >
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
living_room
@ -1138,7 +1133,7 @@ script:
type: '{{ type }}'
- if:
- condition: template
value_template: "{{ who in ['Everywhere','everywhere','all_bedrooms','All Bedrooms','kids_bedrooms','Kids Bedrooms'] }}"
value_template: "{{ get_room_speakers.jarvis_tts == 'group' and get_group_speakers.google is defined }}"
then:
- service: script.jarvis_voice
data:

126
packages/variables.yaml Normal file
View File

@ -0,0 +1,126 @@
script:
get_room_speakers:
alias: Get Room Speakers
sequence:
- variables:
room_services: >-
{% if room in areas() %}
{% set alexa_speaker = states.media_player |
selectattr('entity_id', 'in', area_entities(room)) |
rejectattr('attributes.last_called', 'undefined') |
selectattr('entity_id', 'search', 'echo_dot') |
map(attribute='entity_id') |
list | first %}
{% set google_speaker = states.media_player |
selectattr('entity_id', 'in', area_entities(room)) |
rejectattr('attributes.device_class', 'undefined') |
selectattr('attributes.device_class', 'search', '(speaker)') |
selectattr('entity_id', 'search', 'google') |
map(attribute='entity_id') |
list | first %}
{% set tts = "alexa" if alexa_speaker is defined else "google" %}
{% else %}
{% set tts = "group" %}
{% endif %}
{"area":"{{room}}","alexa_speaker":"{{alexa_speaker|default({}) }}","jarvis_tts":"{{tts|default("google") }}","google_speaker":"{{google_speaker|default({}) }}"}
- stop: "Services acquired"
response_variable: "get_room_speakers"
get_group_speakers:
alias: Get Group Speakers
sequence:
- variables:
get_group_speakers: >-
{% set speakers = expand('group.' + group) | map(attribute='entity_id') | list | join(',') %}
{% set alexa_speakers = expand('group.' + group) |
rejectattr('attributes.last_called', 'undefined') |
selectattr('entity_id', 'search', 'echo_dot') |
map(attribute='entity_id') |
list | join(',') %}
{% set google_speakers = expand('group.' + group) |
rejectattr('attributes.device_class', 'undefined') |
selectattr('attributes.device_class', 'search', '(speaker)') |
selectattr('entity_id', 'search', 'google') |
map(attribute='entity_id') |
list | join(',') %}
{"alexa":"{{alexa_speakers|default({})}}","google":"{{google_speakers|default({})}}"}
- stop: "Speakers acquired"
response_variable: "get_group_speakers"
get_echo_dots:
alias: Get Echo Dots
sequence:
- variables:
get_echo_dots: >-
{% if group is defined %}
{% set speakers = expand('group.' + group) %}
{% else %}
{% set speakers = states.media_player %}
{% endif %}
{% set echo_dots = speakers |
rejectattr('attributes.last_called', 'undefined') |
selectattr('entity_id', 'search', 'echo_dot') |
map(attribute='entity_id') |
list | join(',') %}
{"speakers":"{{echo_dots}}"}
- stop: "Echo Dots acquired"
response_variable: "get_echo_dots"
get_google_speakers:
alias: Get Google Speakers
sequnce:
- variables:
get_google_speakers: >-
{% if group is defined %}
{% set speakers = expand('group.' + group) %}
{% else %}
{% set speakers = states.media_player %}
{% endif %}
{% set google_speaker = speakers |
rejectattr('attributes.device_class', 'undefined') |
selectattr('attributes.device_class', 'search', '(speaker)') |
selectattr('entity_id', 'search', 'google') |
map(attribute='entity_id') |
list | join(',') %}
{"speakers":"{{google_speaker}}"}
- stop: "Google speakers acquired"
response_variable: "get_google_speakers"
get_all_speakers:
alias: Get All Speakers
sequence:
- variables: >-
get_speakers:
{% set alexa_speaker = states.media_player |
rejectattr('attributes.last_called', 'undefined') |
selectattr('entity_id', 'search', 'echo_dot') |
map(attribute='entity_id')
%}
{% set google_speaker = states.media_player |
rejectattr('attributes.device_class', 'undefined') |
selectattr('attributes.device_class', 'search', '(speaker)') |
selectattr('entity_id', 'search', 'google') |
map(attribute='entity_id')
%}
{% set alexa_list = alexa_speaker | list | join(',') %}
{% set google_list = google_speaker | list | join(',') %}
{% set all_speakers = alexa_list + ',' + google_list %}
{"all_speakers":"{{all_speakers}}"}
get_room_lights:
alias: Get Room Lights
sequence:
- variables:
area: >
{{ room }}
entities: >
{% set lights = states.light |
selectattr('entity_id', 'in', area_entities(area)) |
map(attribute='entity_id') |
list | join(',') %}
{"lights":"{{lights}}"}
- stop: "Lights acquired"
response_variable: "entities"