epaper restanzeige
beim anschauen dieses videos habe ich folgendes widget gesehen.

sowas wollte ich auch haben. zunächst habe ich mir von cursor ein markdown-widget für home assistant bauen lassen. das sah dann so aus.

die zeile mit dem leben nehm ich möglicherweise wieder raus weil sie zu frustruierend ist. ich habe cursor mein geburtsdatum verraten und gehe für die statistik davon aus, dass ich 90 jahre alt werde. davon sind bald zwei drittel rum.
der code ist relativ überschaubar:
{% set dots = 28 %}
{% set mins_now = now().hour * 60 + now().minute %} {% set day_p = (mins_now / 1440 * 100) %} {% set week_p = (((now().weekday() * 1440) + mins_now) / (7 * 1440) * 100) %}
{% set next_month = (now().replace(day=28) + timedelta(days=4)).replace(day=1) %} {% set month_total = (next_month - timedelta(days=1)).day %} {% set month_p = (((now().day - 1) * 1440 + mins_now) / (month_total * 1440) * 100) %}
{% set year_total = 366 if now().year % 4 == 0 and (now().year % 100 != 0 or now().year % 400 == 0) else 365 %} {% set year_p = (((now().timetuple().tm_yday - 1) * 1440 + mins_now) / (year_total * 1440) * 100) %}
{% set life_start = as_timestamp('1969-03-16 00:00:00') %} {% set life_end = as_timestamp('2059-03-16 00:00:00') %} {% set life_now = as_timestamp(now()) %} {% set life_p_raw = ((life_now - life_start) / (life_end - life_start) * 100) %} {% set life_p = [0, [life_p_raw, 100] | min] | max %}
{% set weekdays = ['MONTAG','DIENSTAG','MITTWOCH','DONNERSTAG','FREITAG','SAMSTAG','SONNTAG'] %} {% set months = ['JANUAR','FEBRUAR','MÄRZ','APRIL','MAI','JUNI','JULI','AUGUST','SEPTEMBER','OKTOBER','NOVEMBER','DEZEMBER'] %}
{% set day_label = weekdays[now().weekday()] %} {% set week_label = 'WOCHE ' ~ now().isocalendar().week %} {% set month_label = months[now().month - 1] %}
{%- macro bar(p, dots) -%} {%- set f = ((p / 100) * dots) | round(0, 'floor') | int -%} {{- ('●' * f) ~ ('·' * (dots - f)) -}} {%- endmacro -%}
<pre class="ntg">{{ '%-10s'|format(day_label) }} {{ bar(day_p, dots) }} {{ '%3d'|format(day_p|round(0)|int) }}%
{{ '%-10s'|format(week_label) }} {{ bar(week_p, dots) }} {{ '%3d'|format(week_p|round(0)|int) }}%
{{ '%-10s'|format(month_label) }} {{ bar(month_p, dots) }} {{ '%3d'|format(month_p|round(0)|int) }}%
{{ '%-10s'|format(now().year|string) }} {{ bar(year_p, dots) }} {{ '%3d'|format(year_p|round(0)|int) }}%
{{ '%-10s'|format('LEBEN') }} {{ bar(life_p, dots) }} {{ '%3d'|format(life_p|round(0)|int) }}%</pre>
aber dann fiel mir ein, dass ich noch einen epaper tag übrig habe, für den ich keine besonders gute verwendung habe. im flur und kinderzimmer hängen tags die nützlich sind und das datum und das wetter anzeigen. der im flur hängt über einem ipad, das bereits das wetter und datum anzeigt. jetzt zeigt es die restzeiten des tages, der woche, des monats und des jahres an. find ich gut.
