From 705f8008039abd369d4696234a3d408580861bbf Mon Sep 17 00:00:00 2001 From: Joshua King Date: Wed, 25 Jun 2025 15:11:53 -0400 Subject: [PATCH] Refactor check_day_camp script to simplify event condition checks and streamline input_boolean handling --- scripts.yaml | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/scripts.yaml b/scripts.yaml index 6d889a9..fde580e 100644 --- a/scripts.yaml +++ b/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 \ No newline at end of file + 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 \ No newline at end of file