Compare commits

..

4 Commits

3 changed files with 221 additions and 96 deletions

View File

@@ -2967,99 +2967,49 @@
- id: '1696539209438'
alias: Tony Custom Meds Handler
description: ''
triggers:
- minutes: /30
id: trigger30
alias: Every 30 minutes
trigger: time_pattern
- at: input_datetime.tony_custom_meds_notify_p1
trigger:
- platform: time
at: input_datetime.tony_custom_meds_notify_p1
alias: Notify 1
id: p1-notify
trigger: time
- alias: Notify 2
at: input_datetime.tony_custom_meds_notify_p2
id: p2-notify
trigger: time
- entity_id:
- platform: state
entity_id:
- input_boolean.tony_custom_meds_taken_p1
from: 'off'
to: 'on'
id: p1-taken
alias: Taken 1
trigger: state
- alias: Taken 2
entity_id:
- input_datetime.tony_custom_meds_taken_p2
from: 'off'
to: 'on'
id: p2-taken
trigger: state
conditions:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.tony_custom_meds_tracker_p1
state: 'on'
- condition: state
entity_id: input_boolean.tony_custom_meds_tracker_p2
state: 'on'
alias: Any custom med trackers are on
actions:
- alias: Routing
if:
- condition: trigger
id:
- trigger30
condition: []
action:
- variables:
trigger: '{{ trigger.id }}'
num: '{{ trigger[:2] }}'
reason: '{{ trigger.split(''-'')[1] }}'
- if:
- condition: template
value_template: '{% set active = ''input_boolean.tony_custom_meds_tracker_''
+ num %}
{{ is_state(active,''on'') }}'
alias: Check tracker
then:
- variables:
trigger: '{{ trigger.id }}'
num: all
reason: notify
alias: Override variables to indicate this is an interval notify request
- alias: For each reminder entity
repeat:
for_each: '{{ states.input_boolean | selectattr(''entity_id'',''in'',label_entities(''Tony
Custom Meds'')) | selectattr(''entity_id'',''search'',''reminder'') | map(attribute=''entity_id'')
| list }}'
sequence:
- alias: Run custom meds script if tracker is active
if:
- alias: Check tracker
condition: template
value_template: '{{ is_state(repeat.item,''on'') }}'
then:
- data:
num: '{{ num }}'
reason: '{{ reason }}'
alias: Run custom meds script
action: script.tony_custom_meds
else:
- variables:
trigger: '{{ trigger.id }}'
num: '{{ trigger[:2] }}'
reason: '{{ trigger.split(''-'')[1] }}'
- alias: Run custom meds script if tracker is active
if:
- alias: Check tracker
condition: template
value_template: '{{ is_state(repeat.item,''on'') }}'
- if:
- condition: template
value_template: '{{ reason == ''notify'' }}'
alias: Is this a notification
then:
- if:
- condition: template
value_template: '{{ reason == ''notify'' }}'
alias: Is this a notification
then:
- data: {}
target:
entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
alias: Turn off "taken" boolean
action: input_boolean.turn_off
alias: Turn off "taken" boolean if this is a notification
- data:
num: '{{ num }}'
reason: '{{ reason }}'
alias: Run custom meds script
action: script.tony_custom_meds
- service: input_boolean.turn_off
data: {}
target:
entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
alias: Turn off "taken" boolean
alias: Turn off "taken" boolean if this is a notification
- service: script.tony_custom_meds
data:
num: '{{ num }}'
reason: '{{ reason }}'
alias: Run custom meds script
alias: Run custom meds script if tracker is active
mode: parallel
max: 10
- id: '1696556688808'
@@ -5354,6 +5304,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

@@ -47,6 +47,12 @@ input_boolean:
sunset_lights_triggered:
name: Sunset Lights Triggered
icon: mdi:weather-sunset
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

@@ -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: