Refactor check_day_camp script to simplify event condition checks and streamline input_boolean handling
This commit is contained in:
35
scripts.yaml
35
scripts.yaml
@@ -1,22 +1,15 @@
|
||||
- check_day_camp:
|
||||
sequence:
|
||||
- service: calendar.list_events
|
||||
data:
|
||||
start_date: "{{ now().date() }}"
|
||||
end_date: "{{ (now() + timedelta(days=1)).date() }}"
|
||||
target:
|
||||
entity_id: calendar.family_events
|
||||
response_variable: events
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ events.events | default([]) | selectattr('summary', 'search', 'Camp') | rejectattr('summary', 'search', 'No') | list | count > 0 }}
|
||||
sequence:
|
||||
- service: input_boolean.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.day_camp_today
|
||||
default:
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.day_camp_today
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('calendar.family_events') == 'on' and 'Camp' in (state_attr('calendar.family_events', 'message') | default('')) and 'No' not in (state_attr('calendar.family_events', 'message') | default('')) }}
|
||||
sequence:
|
||||
- service: input_boolean.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.day_camp_today
|
||||
default:
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.day_camp_today
|
||||
Reference in New Issue
Block a user