################################################################################ # lunch_menus.yaml # # Pulls Mon–Fri of the current school week from each lunch Google Calendar into # template sensors. On Sat/Sun, advances to next week's Monday. The Lunch Menus # dashboard renders those attributes — the stock calendar card has no school- # week view. ################################################################################ template: - trigger: - platform: time_pattern minutes: "/15" - platform: homeassistant event: start - platform: event event_type: event_template_reloaded action: - variables: # weekday(): Mon=0 … Sun=6. Weekend → next Monday. school_monday: >- {% set wd = now().weekday() %} {% if wd >= 5 %} {{ (today_at() + timedelta(days=(7 - wd))).isoformat() }} {% else %} {{ (today_at() - timedelta(days=wd)).isoformat() }} {% endif %} - action: calendar.get_events target: entity_id: - calendar.bhs_lunch_menu - calendar.bis_school_lunches - calendar.hms_lunch_menu data: start_date_time: "{{ school_monday }}" duration: days: 5 response_variable: agenda sensor: - name: "BHS Lunch Menu Week" unique_id: bhs_lunch_menu_week icon: mdi:food-apple state: "{{ agenda['calendar.bhs_lunch_menu'].events | count }}" attributes: events: "{{ agenda['calendar.bhs_lunch_menu'].events }}" week_start: "{{ school_monday }}" - name: "BIS Lunch Menu Week" unique_id: bis_lunch_menu_week icon: mdi:food-apple state: "{{ agenda['calendar.bis_school_lunches'].events | count }}" attributes: events: "{{ agenda['calendar.bis_school_lunches'].events }}" week_start: "{{ school_monday }}" - name: "HMS Lunch Menu Week" unique_id: hms_lunch_menu_week icon: mdi:food-apple state: "{{ agenda['calendar.hms_lunch_menu'].events | count }}" attributes: events: "{{ agenda['calendar.hms_lunch_menu'].events }}" week_start: "{{ school_monday }}"