Rotating value template

Last year I setup a simple UI element that display my kids’ school daily special. The setup was simple, every Monday they had a specific special for example Art. If there was no school Monday for any reason, Art didn’t happen. Simple!

This year, we’ve got a rotating special schedule… If there is a scheduled day off, the specials don’t increment, otherwise they move along 1-6 but can’t tied to a day of the week.

So far, I’ve pulled in a list of all days off… why are there so many?

I’m looping through to flag if they are supposed to be off:

{% for date in noschooldays %}
  {% if strptime(date,'%m/%d/%Y') == strptime(states('sensor.date'),'%Y-%m-%d') %}
    {% set ns.off = true %}
  {% endif %}
{% endfor %}

All the logic for when to increment the index has been roughed in but I’m not sure how to set the initial condition ie Day 0, special 0, then start incrementing and rolling over after that.

Should I be using more than one sensor? Is there a better structure to use?

Essentially I need the following:

IF it's a school day THEN display the day's special
IF it's a school day after 9a THEN increment the special % 6

My old setup used now().weekday() as an index for the special list, so this isn’t a major jump, it just requires a bit more logic and qualifiers.

TIA

1 Like