Compare commits

..

4 Commits

Author SHA1 Message Date
tm24fan8 b7056c12be Add variables and iron out a few more conditions 2025-12-16 19:44:33 -05:00
tm24fan8 c036e03e27 Add automations and input booleans to max brightness scripts 2025-12-16 19:44:32 -05:00
tm24fan8 975117bb08 Toggles 2025-12-16 19:44:30 -05:00
tm24fan8 f795d98ef3 Automation framework 2025-12-16 19:43:30 -05:00
3 changed files with 221 additions and 96 deletions
+174 -84
View File
@@ -2967,99 +2967,49 @@
- id: '1696539209438' - id: '1696539209438'
alias: Tony Custom Meds Handler alias: Tony Custom Meds Handler
description: '' description: ''
triggers: trigger:
- minutes: /30 - platform: time
id: trigger30 at: input_datetime.tony_custom_meds_notify_p1
alias: Every 30 minutes
trigger: time_pattern
- at: input_datetime.tony_custom_meds_notify_p1
alias: Notify 1 alias: Notify 1
id: p1-notify id: p1-notify
trigger: time - platform: state
- alias: Notify 2 entity_id:
at: input_datetime.tony_custom_meds_notify_p2
id: p2-notify
trigger: time
- entity_id:
- input_boolean.tony_custom_meds_taken_p1 - input_boolean.tony_custom_meds_taken_p1
from: 'off' from: 'off'
to: 'on' to: 'on'
id: p1-taken id: p1-taken
alias: Taken 1 alias: Taken 1
trigger: state condition: []
- alias: Taken 2 action:
entity_id: - variables:
- input_datetime.tony_custom_meds_taken_p2 trigger: '{{ trigger.id }}'
from: 'off' num: '{{ trigger[:2] }}'
to: 'on' reason: '{{ trigger.split(''-'')[1] }}'
id: p2-taken - if:
trigger: state - condition: template
conditions: value_template: '{% set active = ''input_boolean.tony_custom_meds_tracker_''
- condition: or + num %}
conditions:
- condition: state {{ is_state(active,''on'') }}'
entity_id: input_boolean.tony_custom_meds_tracker_p1 alias: Check tracker
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
then: then:
- variables: - if:
trigger: '{{ trigger.id }}' - condition: template
num: all value_template: '{{ reason == ''notify'' }}'
reason: notify alias: Is this a notification
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'') }}'
then: then:
- if: - service: input_boolean.turn_off
- condition: template data: {}
value_template: '{{ reason == ''notify'' }}' target:
alias: Is this a notification entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
then: alias: Turn off "taken" boolean
- data: {} alias: Turn off "taken" boolean if this is a notification
target: - service: script.tony_custom_meds
entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}' data:
alias: Turn off "taken" boolean num: '{{ num }}'
action: input_boolean.turn_off reason: '{{ reason }}'
alias: Turn off "taken" boolean if this is a notification alias: Run custom meds script
- data: alias: Run custom meds script if tracker is active
num: '{{ num }}'
reason: '{{ reason }}'
alias: Run custom meds script
action: script.tony_custom_meds
mode: parallel mode: parallel
max: 10 max: 10
- id: '1696556688808' - id: '1696556688808'
@@ -5354,6 +5304,146 @@
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
+6
View File
@@ -47,6 +47,12 @@ input_boolean:
sunset_lights_triggered: sunset_lights_triggered:
name: Sunset Lights Triggered name: Sunset Lights Triggered
icon: mdi:weather-sunset 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: input_number:
upstairs_bathroom_motion_off_delay: upstairs_bathroom_motion_off_delay:
+41 -12
View File
@@ -108,12 +108,27 @@ global_on:
max_brightness: max_brightness:
sequence: sequence:
- alias: Turn off Adaptive Lighting and Motion Lighting - alias: Turn off Adaptive Lighting and Motion Lighting
data: {} parallel:
target: - service: automation.turn_off
label_id: metadata: {}
- adaptive_lighting data:
- motion_lighting stop_actions: true
action: switch.turn_off 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: - delay:
hours: 0 hours: 0
minutes: 0 minutes: 0
@@ -463,12 +478,26 @@ 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
- service: switch.turn_on - alias: Turn on motion lighting
metadata: {} parallel:
data: {} - service: input_boolean.turn_on
target: metadata: {}
label_id: motion_lighting data: {}
alias: Turn on motion lighting 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 mode: single
icon: mdi:broom icon: mdi:broom
cleanup_crash: cleanup_crash: