Compare commits
6 Commits
stairwell-
...
response_v
Author | SHA1 | Date | |
---|---|---|---|
b48380d152
|
|||
d649d0fa5c
|
|||
abd30f7ff2
|
|||
c32c751e97
|
|||
177c4a9a51
|
|||
ec8e22513c
|
140
automations.yaml
140
automations.yaml
@ -5314,146 +5314,6 @@
|
|||||||
data:
|
data:
|
||||||
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
|
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
|
||||||
}}
|
}}
|
||||||
- id: '1716580842614'
|
|
||||||
alias: Stairwell and Hallway Motion Lighting
|
|
||||||
description: ''
|
|
||||||
trigger:
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
- binary_sensor.stairwell_top_motion
|
|
||||||
to: 'on'
|
|
||||||
from: 'off'
|
|
||||||
id: top-detected
|
|
||||||
alias: Stairwell Top Detected
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
- binary_sensor.stairwell_bottom_motion
|
|
||||||
from: 'off'
|
|
||||||
to: 'on'
|
|
||||||
id: bottom-detected
|
|
||||||
alias: Stairwell Bottom Detected
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
- binary_sensor.stairwell_top_motion
|
|
||||||
from: 'on'
|
|
||||||
to: 'off'
|
|
||||||
id: top-clear
|
|
||||||
alias: Stairwell Top Clear
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
- binary_sensor.stairwell_bottom_motion
|
|
||||||
from: 'on'
|
|
||||||
to: 'off'
|
|
||||||
id: bottom-clear
|
|
||||||
alias: Stairwell Bottom Clear
|
|
||||||
- platform: event
|
|
||||||
event_type: timer.finished
|
|
||||||
event_data:
|
|
||||||
entity_id: timer.stairwell_motion_timer
|
|
||||||
id: stairwell-timer
|
|
||||||
alias: Stairwell Timer Finished
|
|
||||||
- alias: Hallway Timer Finished
|
|
||||||
platform: event
|
|
||||||
event_type: timer.finished
|
|
||||||
event_data:
|
|
||||||
entity_id: timer.upstairs_hallway_motion_timer
|
|
||||||
id: hallway-timer
|
|
||||||
condition: []
|
|
||||||
action:
|
|
||||||
- variables:
|
|
||||||
hallway_scene: "{% set people_sleeping = is_state('input_boolean.emma_sleeping','on')
|
|
||||||
or is_state('input_boolean.kallen_sleeping','on') or is_state('input_boolean.master_bedroom_sleeping','on')
|
|
||||||
%} {% if is_state('input_boolean.night_mode','on') or people_sleeping == true
|
|
||||||
%}\n Nightlight\n{% else %}\n Adaptive\n{% endif %}\n"
|
|
||||||
hallway_action: "{% set people_sleeping = is_state('input_boolean.emma_sleeping','on')
|
|
||||||
or is_state('input_boolean.kallen_sleeping','on') or is_state('input_boolean.master_bedroom_sleeping','on')
|
|
||||||
%} {% if is_state('input_boolean.goodnight','on') %}\n off\n{% elif is_state('input_boolean.night_mode','on')
|
|
||||||
or people_sleeping == true or is_state('binary_sensor.early_night_mode','on')
|
|
||||||
%}\n on\n{% else %}\n off\n{% endif %}\n"
|
|
||||||
- choose:
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- top-detected
|
|
||||||
- condition: numeric_state
|
|
||||||
entity_id: sensor.stairwell_top_illuminance
|
|
||||||
below: input_number.upstairs_hallway_lux_threshold
|
|
||||||
alias: Stairwell Top Illuminance is below lux threshold
|
|
||||||
sequence: []
|
|
||||||
alias: Stairwell Top Detected
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- bottom-detected
|
|
||||||
- alias: Stairwell Bottom Illuminance is below lux threshold
|
|
||||||
condition: numeric_state
|
|
||||||
entity_id: sensor.stairwell_bottom_illuminance
|
|
||||||
below: input_number.stairwell_lux_threshold
|
|
||||||
sequence: []
|
|
||||||
alias: Stairwell Bottom Detected
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- top-clear
|
|
||||||
- alias: Lights are on
|
|
||||||
condition: or
|
|
||||||
conditions:
|
|
||||||
- condition: state
|
|
||||||
entity_id: light.hallway_overhead
|
|
||||||
state: 'on'
|
|
||||||
alias: Hallway Overhead
|
|
||||||
- alias: Stairwell LED Strip
|
|
||||||
condition: state
|
|
||||||
entity_id: light.stairwell_led_strip
|
|
||||||
state: 'on'
|
|
||||||
sequence:
|
|
||||||
- service: timer.start
|
|
||||||
metadata: {}
|
|
||||||
data:
|
|
||||||
duration: '{{ states(''input_number.upstairs_hallway_lights_off_delay'')
|
|
||||||
| int * 60 }}'
|
|
||||||
target:
|
|
||||||
entity_id: timer.upstairs_hallway_motion_timer
|
|
||||||
alias: Start upstairs hallway motion timer
|
|
||||||
alias: Stairwell Top Clear
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- bottom-clear
|
|
||||||
- alias: Lights are on
|
|
||||||
condition: or
|
|
||||||
conditions:
|
|
||||||
- condition: state
|
|
||||||
entity_id: light.hallway_overhead
|
|
||||||
state: 'on'
|
|
||||||
alias: Hallway Overhead
|
|
||||||
- alias: Stairwell LED Strip
|
|
||||||
condition: state
|
|
||||||
entity_id: light.stairwell_led_strip
|
|
||||||
state: 'on'
|
|
||||||
sequence:
|
|
||||||
- service: timer.start
|
|
||||||
metadata: {}
|
|
||||||
data:
|
|
||||||
duration: '{{ states(''input_number.stairwell_lights_off_delay'') | int
|
|
||||||
* 60 }}'
|
|
||||||
target:
|
|
||||||
entity_id: timer.stairwell_motion_timer
|
|
||||||
alias: Start stairwell motion timer
|
|
||||||
alias: Stairwell Bottom Clear
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- hallway-timer
|
|
||||||
sequence: []
|
|
||||||
alias: Hallway Timer Finished
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id:
|
|
||||||
- stairwell-timer
|
|
||||||
sequence: []
|
|
||||||
alias: Stairwell Timer Finished
|
|
||||||
mode: restart
|
|
||||||
|
|
||||||
'
|
'
|
||||||
alias: Set time morning meds were taken
|
alias: Set time morning meds were taken
|
||||||
|
@ -44,12 +44,6 @@ input_boolean:
|
|||||||
adaptive_lighting_adjustments:
|
adaptive_lighting_adjustments:
|
||||||
name: Adaptive Lighting Adjustments
|
name: Adaptive Lighting Adjustments
|
||||||
icon: mdi:knob
|
icon: mdi:knob
|
||||||
upstairs_hallway_motion_lighting:
|
|
||||||
name: Upstairs Hallway Motion Lighting
|
|
||||||
icon: mdi:motion-sensor
|
|
||||||
stairwell_motion_lighting:
|
|
||||||
name: Stairwell Motion Lighting
|
|
||||||
icon: mdi:motion-sensor
|
|
||||||
|
|
||||||
input_number:
|
input_number:
|
||||||
upstairs_bathroom_motion_off_delay:
|
upstairs_bathroom_motion_off_delay:
|
||||||
|
@ -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
|
|
||||||
{% 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
|
script.alexa_voice
|
||||||
{% else %}
|
{% else %}
|
||||||
script.alexa_voice
|
script.jarvis_voice
|
||||||
{% endif %}
|
{% 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"
|
53
scripts.yaml
53
scripts.yaml
@ -108,27 +108,12 @@ global_on:
|
|||||||
max_brightness:
|
max_brightness:
|
||||||
sequence:
|
sequence:
|
||||||
- alias: Turn off Adaptive Lighting and Motion Lighting
|
- alias: Turn off Adaptive Lighting and Motion Lighting
|
||||||
parallel:
|
data: {}
|
||||||
- service: automation.turn_off
|
target:
|
||||||
metadata: {}
|
label_id:
|
||||||
data:
|
- adaptive_lighting
|
||||||
stop_actions: true
|
- motion_lighting
|
||||||
target:
|
action: switch.turn_off
|
||||||
label_id: motion_lighting
|
|
||||||
alias: Automations
|
|
||||||
- alias: Switches
|
|
||||||
service: switch.turn_off
|
|
||||||
data: {}
|
|
||||||
target:
|
|
||||||
label_id:
|
|
||||||
- adaptive_lighting
|
|
||||||
- motion_lighting
|
|
||||||
- service: input_boolean.turn_off
|
|
||||||
metadata: {}
|
|
||||||
data: {}
|
|
||||||
target:
|
|
||||||
label_id: motion_lighting
|
|
||||||
alias: Input Booleans
|
|
||||||
- delay:
|
- delay:
|
||||||
hours: 0
|
hours: 0
|
||||||
minutes: 0
|
minutes: 0
|
||||||
@ -478,26 +463,12 @@ max_brightness_cleanup:
|
|||||||
target:
|
target:
|
||||||
entity_id: input_select.basement_studio_scenes
|
entity_id: input_select.basement_studio_scenes
|
||||||
alias: Set basement lights to adaptive
|
alias: Set basement lights to adaptive
|
||||||
- alias: Turn on motion lighting
|
- service: switch.turn_on
|
||||||
parallel:
|
metadata: {}
|
||||||
- service: input_boolean.turn_on
|
data: {}
|
||||||
metadata: {}
|
target:
|
||||||
data: {}
|
label_id: motion_lighting
|
||||||
target:
|
alias: Turn on motion lighting
|
||||||
label_id: motion_lighting
|
|
||||||
alias: Input Booleans
|
|
||||||
- service: switch.turn_on
|
|
||||||
metadata: {}
|
|
||||||
data: {}
|
|
||||||
target:
|
|
||||||
label_id: motion_lighting
|
|
||||||
alias: Switches
|
|
||||||
- service: automation.turn_on
|
|
||||||
metadata: {}
|
|
||||||
data: {}
|
|
||||||
target:
|
|
||||||
label_id: motion_lighting
|
|
||||||
alias: Automations
|
|
||||||
mode: single
|
mode: single
|
||||||
icon: mdi:broom
|
icon: mdi:broom
|
||||||
cleanup_crash:
|
cleanup_crash:
|
||||||
|
Reference in New Issue
Block a user