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
+159 -69
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:
- 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
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: - variables:
trigger: '{{ trigger.id }}' trigger: '{{ trigger.id }}'
num: '{{ trigger[:2] }}' num: '{{ trigger[:2] }}'
reason: '{{ trigger.split(''-'')[1] }}' reason: '{{ trigger.split(''-'')[1] }}'
- alias: Run custom meds script if tracker is active - if:
if: - condition: template
- alias: Check tracker value_template: '{% set active = ''input_boolean.tony_custom_meds_tracker_''
condition: template + num %}
value_template: '{{ is_state(repeat.item,''on'') }}'
{{ is_state(active,''on'') }}'
alias: Check tracker
then: then:
- if: - if:
- condition: template - condition: template
value_template: '{{ reason == ''notify'' }}' value_template: '{{ reason == ''notify'' }}'
alias: Is this a notification alias: Is this a notification
then: then:
- data: {} - service: input_boolean.turn_off
data: {}
target: target:
entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}' entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
alias: Turn off "taken" boolean alias: Turn off "taken" boolean
action: input_boolean.turn_off
alias: Turn off "taken" boolean if this is a notification alias: Turn off "taken" boolean if this is a notification
- data: - service: script.tony_custom_meds
data:
num: '{{ num }}' num: '{{ num }}'
reason: '{{ reason }}' reason: '{{ reason }}'
alias: Run custom meds script alias: Run custom meds script
action: script.tony_custom_meds alias: Run custom meds script if tracker is active
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:
+31 -2
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
parallel:
- service: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
label_id: motion_lighting
alias: Automations
- alias: Switches
service: switch.turn_off
data: {} data: {}
target: target:
label_id: label_id:
- adaptive_lighting - adaptive_lighting
- motion_lighting - motion_lighting
action: switch.turn_off - 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
- 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 - service: switch.turn_on
metadata: {} metadata: {}
data: {} data: {}
target: target:
label_id: motion_lighting label_id: motion_lighting
alias: Turn on 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: