Compare commits
6 Commits
status-rew
...
response_v
Author | SHA1 | Date | |
---|---|---|---|
b48380d152
|
|||
d649d0fa5c
|
|||
abd30f7ff2
|
|||
c32c751e97
|
|||
177c4a9a51
|
|||
ec8e22513c
|
@ -980,7 +980,33 @@ script:
|
|||||||
- critical
|
- critical
|
||||||
variables:
|
variables:
|
||||||
voice: "{{ states('input_select.jarvis_voice') }}"
|
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:
|
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
|
- service: mqtt.publish
|
||||||
data:
|
data:
|
||||||
topic: 'house/polly/lastmsg'
|
topic: 'house/polly/lastmsg'
|
||||||
@ -1024,44 +1050,13 @@ script:
|
|||||||
- service: >-
|
- service: >-
|
||||||
{% if voice == 'nabu' %}
|
{% if voice == 'nabu' %}
|
||||||
script.nabu_voice
|
script.nabu_voice
|
||||||
{% elif who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
|
{% elif get_room_services.jarvis_tts in ['group','alexa'] %}
|
||||||
script.alexa_voice
|
|
||||||
{% elif who in ['kallen_bedroom','Kallen Bedroom'] %}
|
|
||||||
{% if is_state('input_boolean.kallen_sleeping','on') and type not in ['critical','Critical'] %}
|
|
||||||
script.alexa_voice
|
script.alexa_voice
|
||||||
{% else %}
|
{% else %}
|
||||||
script.jarvis_voice
|
script.jarvis_voice
|
||||||
{% endif %}
|
{% 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:
|
data:
|
||||||
|
# Work on where this redirect logic should go
|
||||||
who: >
|
who: >
|
||||||
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
|
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
|
||||||
living_room
|
living_room
|
||||||
@ -1138,7 +1133,7 @@ script:
|
|||||||
type: '{{ type }}'
|
type: '{{ type }}'
|
||||||
- if:
|
- if:
|
||||||
- condition: template
|
- 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:
|
then:
|
||||||
- service: script.jarvis_voice
|
- service: script.jarvis_voice
|
||||||
data:
|
data:
|
||||||
|
126
packages/variables.yaml
Normal file
126
packages/variables.yaml
Normal 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"
|
Reference in New Issue
Block a user