Show Mon–Fri school lunch menus in a full-width panel layout.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
# Lunch Menus — school cafeteria calendars (one week each)
|
# Lunch Menus — school cafeteria calendars (Mon–Fri each)
|
||||||
#
|
#
|
||||||
# Three Google Calendar entities, each shown in listWeek so the wall/panel
|
# Panel layout so the title spans the full width and the three school cards
|
||||||
# view stays focused on the current week instead of a full month grid.
|
# sit in one row. Menus come from packages/lunch_menus.yaml (stock calendar
|
||||||
|
# cards cannot limit to a school-week window).
|
||||||
title: Lunch Menus
|
title: Lunch Menus
|
||||||
theme: cubecraft
|
theme: cubecraft
|
||||||
views:
|
views:
|
||||||
@@ -9,12 +10,21 @@ views:
|
|||||||
path: lunch-menus
|
path: lunch-menus
|
||||||
icon: mdi:food-apple
|
icon: mdi:food-apple
|
||||||
theme: cubecraft
|
theme: cubecraft
|
||||||
type: masonry
|
type: panel
|
||||||
|
cards:
|
||||||
|
- type: vertical-stack
|
||||||
cards:
|
cards:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
content: |
|
content: |
|
||||||
|
{% set wd = now().weekday() %}
|
||||||
|
{% if wd >= 5 %}
|
||||||
|
{% set monday = today_at() + timedelta(days=(7 - wd)) %}
|
||||||
|
{% else %}
|
||||||
|
{% set monday = today_at() - timedelta(days=wd) %}
|
||||||
|
{% endif %}
|
||||||
|
{% set friday = monday + timedelta(days=4) %}
|
||||||
# School Lunch Menus
|
# School Lunch Menus
|
||||||
## Week of {{ now().strftime("%B %d, %Y") }}
|
## {{ monday.strftime("%b %-d") }} – {{ friday.strftime("%b %-d, %Y") }}
|
||||||
card_mod:
|
card_mod:
|
||||||
style: |
|
style: |
|
||||||
ha-card {
|
ha-card {
|
||||||
@@ -42,31 +52,126 @@ views:
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
- type: calendar
|
- type: grid
|
||||||
|
columns: 3
|
||||||
|
square: false
|
||||||
|
cards:
|
||||||
|
- type: markdown
|
||||||
title: BHS Lunch Menu
|
title: BHS Lunch Menu
|
||||||
initial_view: listWeek
|
entity_id: sensor.bhs_lunch_menu_week
|
||||||
entities:
|
content: |
|
||||||
- calendar.bhs_lunch_menu
|
{% set events = state_attr('sensor.bhs_lunch_menu_week', 'events') or [] %}
|
||||||
card_mod: &cc_calendar
|
{% if events is string %}{% set events = [] %}{% endif %}
|
||||||
|
{% set wd = now().weekday() %}
|
||||||
|
{% if wd >= 5 %}
|
||||||
|
{% set monday = today_at() + timedelta(days=(7 - wd)) %}
|
||||||
|
{% else %}
|
||||||
|
{% set monday = today_at() - timedelta(days=wd) %}
|
||||||
|
{% endif %}
|
||||||
|
{% for offset in range(5) %}
|
||||||
|
{% set d = (monday + timedelta(days=offset)).date() %}
|
||||||
|
{% set d_str = d.isoformat() %}
|
||||||
|
{% set ns = namespace(found=false) %}
|
||||||
|
### {{ d.strftime("%A") }}
|
||||||
|
{{ d.strftime("%b %-d") }}
|
||||||
|
{% for e in events if e.start is defined and e.start[:10] == d_str %}
|
||||||
|
{% set ns.found = true %}
|
||||||
|
- {{ e.summary }}
|
||||||
|
{% endfor %}
|
||||||
|
{% if not ns.found %}
|
||||||
|
_No menu listed_
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
card_mod: &cc_menu
|
||||||
style: |
|
style: |
|
||||||
ha-card {
|
ha-card .card-header {
|
||||||
--calendar-day-color: var(--cc-text, var(--primary-text-color));
|
color: var(--cc-text, var(--primary-text-color));
|
||||||
--calendar-day-weekday-color: var(--cc-text-muted, var(--secondary-text-color));
|
font-weight: 700;
|
||||||
--fc-today-bg-color: var(--cc-accent-soft);
|
}
|
||||||
--fc-event-bg-color: var(--cc-accent);
|
ha-markdown {
|
||||||
--fc-event-border-color: var(--cc-accent);
|
padding-top: 0 !important;
|
||||||
|
}
|
||||||
|
ha-markdown h3 {
|
||||||
|
margin: 0.85rem 0 0.15rem 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--cc-accent, var(--primary-color));
|
||||||
|
}
|
||||||
|
ha-markdown h3:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
ha-markdown p {
|
||||||
|
margin: 0 0 0.35rem 0;
|
||||||
|
color: var(--cc-text-muted, var(--secondary-text-color));
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
ha-markdown ul {
|
||||||
|
margin: 0 0 0.5rem 0;
|
||||||
|
padding-left: 1.1rem;
|
||||||
|
}
|
||||||
|
ha-markdown li {
|
||||||
|
margin: 0.15rem 0;
|
||||||
|
color: var(--cc-text, var(--primary-text-color));
|
||||||
|
}
|
||||||
|
ha-markdown em {
|
||||||
|
color: var(--cc-text-muted, var(--secondary-text-color));
|
||||||
}
|
}
|
||||||
|
|
||||||
- type: calendar
|
- type: markdown
|
||||||
title: BIS School Lunches
|
title: BIS School Lunches
|
||||||
initial_view: listWeek
|
entity_id: sensor.bis_lunch_menu_week
|
||||||
entities:
|
content: |
|
||||||
- calendar.bis_school_lunches
|
{% set events = state_attr('sensor.bis_lunch_menu_week', 'events') or [] %}
|
||||||
card_mod: *cc_calendar
|
{% if events is string %}{% set events = [] %}{% endif %}
|
||||||
|
{% set wd = now().weekday() %}
|
||||||
|
{% if wd >= 5 %}
|
||||||
|
{% set monday = today_at() + timedelta(days=(7 - wd)) %}
|
||||||
|
{% else %}
|
||||||
|
{% set monday = today_at() - timedelta(days=wd) %}
|
||||||
|
{% endif %}
|
||||||
|
{% for offset in range(5) %}
|
||||||
|
{% set d = (monday + timedelta(days=offset)).date() %}
|
||||||
|
{% set d_str = d.isoformat() %}
|
||||||
|
{% set ns = namespace(found=false) %}
|
||||||
|
### {{ d.strftime("%A") }}
|
||||||
|
{{ d.strftime("%b %-d") }}
|
||||||
|
{% for e in events if e.start is defined and e.start[:10] == d_str %}
|
||||||
|
{% set ns.found = true %}
|
||||||
|
- {{ e.summary }}
|
||||||
|
{% endfor %}
|
||||||
|
{% if not ns.found %}
|
||||||
|
_No menu listed_
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
- type: calendar
|
{% endfor %}
|
||||||
|
card_mod: *cc_menu
|
||||||
|
|
||||||
|
- type: markdown
|
||||||
title: HMS Lunch Menu
|
title: HMS Lunch Menu
|
||||||
initial_view: listWeek
|
entity_id: sensor.hms_lunch_menu_week
|
||||||
entities:
|
content: |
|
||||||
- calendar.hms_lunch_menu
|
{% set events = state_attr('sensor.hms_lunch_menu_week', 'events') or [] %}
|
||||||
card_mod: *cc_calendar
|
{% if events is string %}{% set events = [] %}{% endif %}
|
||||||
|
{% set wd = now().weekday() %}
|
||||||
|
{% if wd >= 5 %}
|
||||||
|
{% set monday = today_at() + timedelta(days=(7 - wd)) %}
|
||||||
|
{% else %}
|
||||||
|
{% set monday = today_at() - timedelta(days=wd) %}
|
||||||
|
{% endif %}
|
||||||
|
{% for offset in range(5) %}
|
||||||
|
{% set d = (monday + timedelta(days=offset)).date() %}
|
||||||
|
{% set d_str = d.isoformat() %}
|
||||||
|
{% set ns = namespace(found=false) %}
|
||||||
|
### {{ d.strftime("%A") }}
|
||||||
|
{{ d.strftime("%b %-d") }}
|
||||||
|
{% for e in events if e.start is defined and e.start[:10] == d_str %}
|
||||||
|
{% set ns.found = true %}
|
||||||
|
- {{ e.summary }}
|
||||||
|
{% endfor %}
|
||||||
|
{% if not ns.found %}
|
||||||
|
_No menu listed_
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
card_mod: *cc_menu
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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 }}"
|
||||||
Reference in New Issue
Block a user