Compare commits

..

4 Commits

5 changed files with 222 additions and 168 deletions

View File

@ -5314,6 +5314,146 @@
data:
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

View File

@ -44,6 +44,12 @@ input_boolean:
adaptive_lighting_adjustments:
name: Adaptive Lighting Adjustments
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:
upstairs_bathroom_motion_off_delay:

View File

@ -980,33 +980,7 @@ 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'
@ -1050,13 +1024,44 @@ script:
- service: >-
{% if voice == 'nabu' %}
script.nabu_voice
{% elif get_room_services.jarvis_tts in ['group','alexa'] %}
{% 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'] %}
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.jarvis_voice
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
@ -1133,7 +1138,7 @@ script:
type: '{{ type }}'
- if:
- condition: template
value_template: "{{ get_room_speakers.jarvis_tts == 'group' and get_group_speakers.google is defined }}"
value_template: "{{ who in ['Everywhere','everywhere','all_bedrooms','All Bedrooms','kids_bedrooms','Kids Bedrooms'] }}"
then:
- service: script.jarvis_voice
data:

View File

@ -1,126 +0,0 @@
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"

View File

@ -108,12 +108,27 @@ global_on:
max_brightness:
sequence:
- alias: Turn off Adaptive Lighting and Motion Lighting
data: {}
target:
label_id:
- adaptive_lighting
- motion_lighting
action: switch.turn_off
parallel:
- service: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
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:
hours: 0
minutes: 0
@ -463,12 +478,26 @@ max_brightness_cleanup:
target:
entity_id: input_select.basement_studio_scenes
alias: Set basement lights to adaptive
- service: switch.turn_on
metadata: {}
data: {}
target:
label_id: motion_lighting
alias: Turn on motion lighting
- alias: Turn on motion lighting
parallel:
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
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
icon: mdi:broom
cleanup_crash: