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:
|
- check_day_camp:
|
||||||
sequence:
|
sequence:
|
||||||
- service: calendar.list_events
|
- choose:
|
||||||
data:
|
- conditions:
|
||||||
start_date: "{{ now().date() }}"
|
- condition: template
|
||||||
end_date: "{{ (now() + timedelta(days=1)).date() }}"
|
value_template: >
|
||||||
target:
|
{{ 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('')) }}
|
||||||
entity_id: calendar.family_events
|
sequence:
|
||||||
response_variable: events
|
- service: input_boolean.turn_on
|
||||||
- choose:
|
target:
|
||||||
- conditions:
|
entity_id: input_boolean.day_camp_today
|
||||||
- condition: template
|
default:
|
||||||
value_template: >
|
- service: input_boolean.turn_off
|
||||||
{{ events.events | default([]) | selectattr('summary', 'search', 'Camp') | rejectattr('summary', 'search', 'No') | list | count > 0 }}
|
target:
|
||||||
sequence:
|
entity_id: input_boolean.day_camp_today
|
||||||
- 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