How can i show only show future dates from the ugeplan and ugeplan_next
Thanks for the great integration! Is it possible to only show future events from the ugeplan or ugeplan_next on the dashboard? I have tried with a template but is it well above my ability... Another thought i had was to add the information to a calendar which i could then show with the time table information.
Hi there.
You could show the ugeplan_next attribute on your dashboard using a markdown card. Is that what you are looking for?
Events in the "ugeplan" are all free text. Meaning it would be difficult to parse and put into a calendar.
Hi thanks for your reply. I do have the markdown card like your example. It is good but often the information is in the past. It would be great to see what tomorrow’s information with a dropdown to show all future entries. I don’t know if it is the same for everyone but my data always has the date wrapped in h3 tags. I tried to create a template sensor but I couldn’t get it to work. Do you think it is a good approach or is there a simpler way?
here is my template sensor that is working for now.
template:
- sensor:
-
name: "Annabell Ugeplan Next Day" state: > {# English-to-Danish month conversion #} {% set month_map = { "Jan.": "jan.", "Feb.": "feb.", "Mar.": "mar.", "Apr.": "apr.", "May.": "maj.", "Jun.": "jun.", "Jul.": "jul.", "Aug.": "aug.", "Sep.": "sep.", "Oct.": "okt.", "Nov.": "nov.", "Dec.": "dec." } %}
{# Get tomorrow's date in Home Assistant's format #} {% set ha_tomorrow = (now() + timedelta(days=1)).strftime('%-d. %b.') %}
{# Convert the month part to Danish #} {% set en_month = ha_tomorrow.split()[1] %} {% set danish_month = month_map.get(en_month, en_month) %}
{# Rebuild tomorrow's date with the correct Danish month #} {% set danish_tomorrow = ha_tomorrow.replace(en_month, danish_month).lower() %}
{# Extract 'ugeplan_next' attribute #} {% set ugeplan_next = state_attr('sensor.mosedeskolen_annabell', 'ugeplan_next') %} {% if ugeplan_next %} {% set lines = ugeplan_next.split('
') %} {% for line in lines %} {% if danish_tomorrow in line.lower() %} {{ line | replace('
', '') | trim }} {% endif %} {% endfor %} {% else %} "No data available" {% endif %} attributes: details: > {% set ugeplan_next = state_attr('sensor.mosedeskolen_annabell', 'ugeplan_next') %} {% if ugeplan_next %} {% set lines = ugeplan_next.split('') %} {% set month_map = { "Jan.": "jan.", "Feb.": "feb.", "Mar.": "mar.", "Apr.": "apr.", "May.": "maj.", "Jun.": "jun.", "Jul.": "jul.", "Aug.": "aug.", "Sep.": "sep.", "Oct.": "okt.", "Nov.": "nov.", "Dec.": "dec." } %}
{% set ha_tomorrow = (now() + timedelta(days=1)).strftime('%-d. %b.') %} {% set en_month = ha_tomorrow.split()[1] %} {% set danish_month = month_map.get(en_month, en_month) %} {% set danish_tomorrow = ha_tomorrow.replace(en_month, danish_month).lower() %} {% for line in lines %} {% if danish_tomorrow in line.lower() %} {{ line | replace('</h3>', '\n') | trim }} {% endif %} {% endfor %} {% else %} "No data available" {% endif %}
-