epa­per restan­zei­ge

felix schwenzel in artikel

beim an­schau­en die­ses vi­de­os habe ich fol­gen­des wid­get ge­se­hen.

screenshot von marques brownlee review des „Nothing Phone 4A/Pro“. es zeigt ein widget das die prozentualen restzeiten des aktuellen tages, der woche, des monats und des jahres anzeigt.

so­was woll­te ich auch ha­ben. zu­nächst habe ich mir von cur­sor ein mark­down-wid­get für home as­sistant bau­en las­sen. das sah dann so aus.

markdown-wodget in meinem home assistant dashboard. es zeigt die prozentualen restzeiten des aktuellen tages, der woche, des monats, des jahres und meines lebens.

die zei­le mit dem le­ben nehm ich mög­li­cher­wei­se wie­der raus weil sie zu frus­tru­ie­rend ist. ich habe cur­sor mein ge­burts­da­tum ver­ra­ten und gehe für die sta­tis­tik da­von aus, dass ich 90 jah­re alt wer­de. da­von sind bald zwei drit­tel rum.

der code ist re­la­tiv über­schau­bar:

{% 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 ei­nen epa­per tag üb­rig habe, für den ich kei­ne be­son­ders gute ver­wen­dung habe. im flur und kin­der­zim­mer hän­gen tags die nütz­lich sind und das da­tum und das wet­ter an­zei­gen. der im flur hängt über ei­nem ipad, das be­reits das wet­ter und da­tum an­zeigt. jetzt zeigt es die rest­zei­ten des ta­ges, der wo­che, des mo­nats und des jah­res an. find ich gut.

screenshot aus meinem home assistant dashbord. er zeigt die bilschirminhalte meiner drei epaper tags