3 Commits

6 changed files with 334 additions and 423 deletions
+67 -110
View File
@@ -139,10 +139,6 @@
trigger: time
conditions: []
actions:
- action: notify.mobile_app_apollo
data:
message: Lodere es, Lustknabe.
title: 420!
- data:
title: 420!
message: Lodere es, Lustknabe.
@@ -183,6 +179,10 @@
topic: awtrix_desk/notify
payload: '{"text": "420, lodere es, Lustknabe!"}'
action: mqtt.publish
- action: notify.mobile_app_apollo
data:
message: Lodere es, Lustknabe.
title: 420!
mode: single
- id: '1623911524804'
alias: TV Anti-Reflexion (undo)
@@ -227,28 +227,28 @@
action: light.turn_on
- data:
cache: true
media_player_entity_id: media_player.home_assistant_voice_0a7c6b
media_player_entity_id: media_player.home_assistant_voice_0a7c6b_media_player
message: Ab ins Bett, Schlafenszeit.
target:
entity_id: tts.piper
action: tts.speak
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player_2
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player
message: Ab ins Bett, Schlafenszeit.
target:
entity_id: tts.piper
action: tts.speak
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.m5stack_atom_echo
message: Ab ins Bett, Schlafenszeit.
target:
entity_id: tts.piper
action: tts.speak
enabled: true
action: tts.speak
mode: single
- id: '1623954512941'
alias: Licht im Schlafzimmer zum Aufwachen einschalten
@@ -278,8 +278,10 @@
alias: 'Anruf: Beim Klingeln grün blinken'
description: ''
triggers:
- entity_id: sensor.fritz_box_7490_call_monitor_dem_commander1024_seine_cloud
to: ringing
- entity_id:
- sensor.fritz_box_7690_anrufmonitor_dem_commander1024_seine_cloud
to:
- ringing
trigger: state
- entity_id:
- sensor.le2123_phone_state_2
@@ -301,8 +303,8 @@
- 0
target:
entity_id:
- light.awtrix_desk_indicator_1
- light.awtrix_kitchen_indicator_1
- light.awtrix_b8658c_indicator_1
- light.awtrix_528bd4_indicator_1
action: light.turn_on
- data:
scene_id: wled_last_state
@@ -335,16 +337,18 @@
- data: {}
target:
entity_id:
- light.awtrix_desk_indicator_1
- light.awtrix_kitchen_indicator_1
- light.awtrix_b8658c_indicator_1
- light.awtrix_528bd4_indicator_1
action: light.turn_off
mode: single
- id: '1625481640348'
alias: 'Anruf: Beim Telefonieren Musik pausieren'
description: ''
triggers:
- entity_id: sensor.fritz_box_7490_call_monitor_telefonbuch
to: talking
- entity_id:
- sensor.fritz_box_7690_anrufmonitor_dem_commander1024_seine_cloud
to:
- talking
trigger: state
- entity_id:
- sensor.le2123_phone_state_2
@@ -362,9 +366,8 @@
- data:
scene_id: media_last_state
snapshot_entities:
- media_player.wohnzimmer_main
- media_player.wohnzimmer
- media_player.lg_webos_smart_tv
- media_player.ccze
- media_player.spotify_marcus_scholz
- media_player.xboxonex
action: scene.create
@@ -385,7 +388,7 @@
trigger: state
- target:
entity_id:
- scene.media_last_state
- scene.wled_last_state
action: scene.turn_on
data: {}
mode: single
@@ -615,12 +618,33 @@
action: notify.mobile_app_le2123
- data:
cache: true
media_player_entity_id: media_player.raspiaudio_muse_luxe
media_player_entity_id: media_player.home_assistant_voice_0a7c6b_media_player
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.m5stack_atom_echo
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
variables:
message: 'Die Außentemperatur ist mit {{states(''sensor.aussentemperatur'')}}
@@ -665,12 +689,33 @@
action: notify.mobile_app_le2123
- data:
cache: true
media_player_entity_id: media_player.raspiaudio_muse_luxe
media_player_entity_id: media_player.home_assistant_voice_0a7c6b_media_player
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.home_assistant_voice_09c0e7_media_player
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
- data:
cache: true
media_player_entity_id: media_player.m5stack_atom_echo
message: '{{message}}
'
target:
entity_id: tts.piper
enabled: true
action: tts.speak
mode: single
variables:
@@ -1393,91 +1438,3 @@
device_id: 6d1be741876624a70ab5b01b54c6fd6f
entity_id: 621e4377a089b7f5d92c7c9f2cc171a1
domain: switch
- id: '1773000000001'
alias: epaperframe - Kalender Events laden
description: Ruft alle Events von calendar.privat und calendar.tkrz_kalender für heute und morgen ab und schreibt sie in input_text-Helfer.
triggers:
# Täglich um 00:01 neu holen
- trigger: time
at: '00:01:00'
id: daily
actions:
# ── Events für heute (00:00 bis 23:59) holen ──
- action: calendar.get_events
target:
entity_id:
- calendar.privat
- calendar.tkrz_kalender
data:
start_date_time: "{{ now().replace(hour=0, minute=0, second=0) }}"
end_date_time: "{{ (now().replace(hour=0, minute=0, second=0) + timedelta(days=1)) }}"
response_variable: today_evts
# ── Events für morgen (00:00 bis 23:59) holen ──
- action: calendar.get_events
target:
entity_id:
- calendar.privat
- calendar.tkrz_kalender
data:
start_date_time: "{{ (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0) }}"
end_date_time: "{{ (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0) + timedelta(days=1) }}"
response_variable: tomorrow_evts
# ── input_text Helfer schreiben ──
- action: input_text.set_value
target:
entity_id: input_text.kalender_heute_privat
data:
value: >-
{%- set evts = today_evts['calendar.privat']['events'] if 'calendar.privat' in today_evts else [] -%}
{%- set items = [] -%}
{%- for e in evts[:5] -%}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' -%}
{%- set st = e['start'] if e is mapping and 'start' in e else '' -%}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' -%}
{%- set items = items + [hhmm ~ ' - ' ~ s] -%}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
- action: input_text.set_value
target:
entity_id: input_text.kalender_heute_arbeit
data:
value: >-
{%- set evts = today_evts['calendar.tkrz_kalender']['events'] if 'calendar.tkrz_kalender' in today_evts else [] -%}
{%- set items = [] -%}
{%- for e in evts[:5] -%}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' -%}
{%- set st = e['start'] if e is mapping and 'start' in e else '' -%}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' -%}
{%- set items = items + [hhmm ~ ' - ' ~ s] -%}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
- action: input_text.set_value
target:
entity_id: input_text.kalender_morgen_privat
data:
value: >-
{%- set evts = tomorrow_evts['calendar.privat']['events'] if 'calendar.privat' in tomorrow_evts else [] -%}
{%- set items = [] -%}
{%- for e in evts[:5] -%}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' -%}
{%- set st = e['start'] if e is mapping and 'start' in e else '' -%}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' -%}
{%- set items = items + [hhmm ~ ' - ' ~ s] -%}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
- action: input_text.set_value
target:
entity_id: input_text.kalender_morgen_arbeit
data:
value: >-
{%- set evts = tomorrow_evts['calendar.tkrz_kalender']['events'] if 'calendar.tkrz_kalender' in tomorrow_evts else [] -%}
{%- set items = [] -%}
{%- for e in evts[:5] -%}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' -%}
{%- set st = e['start'] if e is mapping and 'start' in e else '' -%}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' -%}
{%- set items = items + [hhmm ~ ' - ' ~ s] -%}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
+3 -3
View File
@@ -35,6 +35,9 @@ utility_meter: !include utility_meters.yaml
mqtt: !include mqtt.yaml
mqtt_statestream: !include mqtt_statestream.yaml
# Calendar data is normalised in a sandboxed script before ESPHome receives it.
python_script:
# Template sensors
template: !include template.yaml
@@ -49,9 +52,6 @@ sql:
# calendar integration
calendar: !include calendars.yaml
# Helpers for epaperframe calendar display
input_text: !include text_helpers.yaml
# DB-recorder configuration
recorder: !include recorder.yaml
+155 -268
View File
@@ -15,7 +15,7 @@ esphome:
priority: -10
then:
- delay: 10s
- display.page.show: calendar # temporary for power page dev
- display.page.show: environment # temporary for power page dev
- component.update: epaper
esp32:
@@ -23,13 +23,10 @@ esp32:
framework:
type: esp-idf
network:
enable_ipv6: true
wifi:
ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk
# use_address: epaperframe.home
use_address: epaperframe.home
power_save_mode: high
fast_connect: on
min_auth_mode: WPA2
@@ -186,29 +183,7 @@ sensor:
entity_id: sensor.serverroom_serveraum_temperatur
id: temp_serverroom
- platform: homeassistant
entity_id: sensor.netzleistung
id: power_total
- platform: homeassistant
entity_id: sensor.serverraum_power
id: power_serverroom
- platform: homeassistant
entity_id: sensor.schreibtisch_power
id: desk_livingroom
- platform: homeassistant
entity_id: sensor.wohnzimmer_heimkino_power
id: media_livingroom
- platform: homeassistant
entity_id: sensor.schlafzimmer_bett_power
id: bedlight_sleepingroom
- platform: homeassistant
entity_id: sensor.schlafzimmer_heimkino_power
id: media_sleepingroom
- platform: homeassistant
entity_id: sensor.radioaktive_strahlungsleistung
@@ -237,33 +212,13 @@ text_sensor:
entity_id: weather.zuhause
id: weather
# ── Kalender-Ereignisse (from HA input_text helpers) ──
# Display-ready JSON produced by the Home Assistant calendar template sensor.
- platform: homeassistant
entity_id: sensor.kalender_heute_privat
id: kalender_heute_privat
internal: true
entity_id: sensor.epaper_kalenderdaten
attribute: entries
id: calendar_entries
- platform: homeassistant
entity_id: sensor.kalender_heute_arbeit
id: kalender_heute_arbeit
internal: true
- platform: homeassistant
entity_id: sensor.kalender_morgen_privat
id: kalender_morgen_privat
internal: true
- platform: homeassistant
entity_id: sensor.kalender_morgen_arbeit
id: kalender_morgen_arbeit
internal: true
graph:
- id: line_power_graph
sensor: power_total
duration: 2h
width: 235
height: 100
time:
- platform: homeassistant
@@ -1134,237 +1089,169 @@ display:
ESP_LOGI("WiFi", "Unlikely");
}
}
- id: calendar
lambda: |-
/* Fetch today and tomorrow dates */
auto now = id(homeassistant_time).now();
int today_day = now.day_of_month;
int today_month = now.month;
int today_wday = now.day_of_week; // 0=Sunday .. 6=Saturday
const char* weekdays[] = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"};
const char* today_weekday_str = weekdays[today_wday];
int today_year = now.year;
const char *months[] = {"Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember"};
const char *weekdays[] = {"Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"};
/* Tomorrow's date */
int tomorrow_day = today_day + 1;
int tomorrow_month = today_month;
int tomorrow_wday = (today_wday + 1) % 7;
const char* tomorrow_weekday_str = weekdays[tomorrow_wday];
int tomorrow_year = today_year;
const int year = now.year;
const int month = now.month;
const int today = now.day_of_month;
/* C1024 logo */
it.image(10, 37, id(c1024_logo));
auto days_in_month = [](int calendar_year, int calendar_month) {
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (calendar_month == 2) {
return (calendar_year % 4 == 0 && (calendar_year % 100 != 0 || calendar_year % 400 == 0)) ? 29 : 28;
}
return days[calendar_month - 1];
};
auto weekday_monday = [](int calendar_year, int calendar_month, int day) {
const int offsets[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
calendar_year -= calendar_month < 3;
const int sunday_first = (calendar_year + calendar_year / 4 - calendar_year / 100 +
calendar_year / 400 + offsets[calendar_month - 1] + day) % 7;
return (sunday_first + 6) % 7;
};
auto iso_weeks_in_year = [&weekday_monday](int calendar_year) {
// 28 December is always in the final ISO week of its year.
const int day_of_year = 362 + ((calendar_year % 4 == 0 &&
(calendar_year % 100 != 0 || calendar_year % 400 == 0)) ? 1 : 0);
const int weekday = weekday_monday(calendar_year, 12, 28) + 1;
return (day_of_year - weekday + 10) / 7;
};
auto iso_week = [&weekday_monday, &days_in_month, &iso_weeks_in_year](int calendar_year, int calendar_month, int day) {
int day_of_year = day;
for (int current_month = 1; current_month < calendar_month; current_month++) {
day_of_year += days_in_month(calendar_year, current_month);
}
const int weekday = weekday_monday(calendar_year, calendar_month, day) + 1;
int week = (day_of_year - weekday + 10) / 7;
if (week < 1) return iso_weeks_in_year(calendar_year - 1);
if (week > iso_weeks_in_year(calendar_year)) return 1;
return week;
};
/* ── LEFT PANE: Today ── */
int leftX = 10;
int leftY = 70; // start below header row
/* LEFT PANE: agenda */
it.image(10, 10, id(c1024_logo));
it.print(100, 27, id(roboto_med_30), TextAlign::BASELINE_LEFT, "TERMINE");
it.line(10, 55, 355, 55);
it.line(365, 10, 365, 352);
it.print(15 + leftX, 10 + leftY, id(sensor_unit), "Heute");
it.filled_rectangle(80 + leftX, 21 + leftY, 240, 3);
DynamicJsonDocument calendar_doc(3072);
const DeserializationError calendar_error = deserializeJson(calendar_doc, id(calendar_entries).state.c_str());
JsonArray calendar_days = calendar_doc.as<JsonArray>();
int agenda_y = 72;
bool has_events = false;
bool has_hidden_events = false;
/* Today's date strip */
it.printf(50 + leftX, 50 + leftY, id(big_sensor_font), "%d", today_day);
it.printf(145 + leftX, 45 + leftY, id(sub_sensor_font), "%s.", today_weekday_str);
it.printf(205 + leftX, 45 + leftY, id(sensor_unit), "%02d.%04d.", today_month, today_year);
/* Event lines (Privat / Arbeit) */
int eventOffsetY = 90;
// Helper lambda: draw one event line at given Y offset with the given text sensor id
// Privat today
if (id(kalender_heute_privat).has_state() && !id(kalender_heute_privat).state.empty()) {
it.print(10 + leftX, 50 + leftY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
// Split by │ separator and display first line of events
auto parts = id(kalender_heute_privat).state.c_str();
it.printf(40 + leftX, 50 + leftY + eventOffsetY, id(sub_sensor_font), "%s",
id(kalender_heute_privat).state.substr(0, 60).c_str());
if (calendar_error || calendar_days.isNull()) {
it.print(18, agenda_y, id(sensor_unit), TextAlign::TOP_LEFT, "Kalenderdaten werden geladen ...");
} else if (calendar_days.size() == 0) {
it.print(18, agenda_y, id(sensor_unit), TextAlign::TOP_LEFT, "Keine Termine in den nächsten Tagen.");
} else {
it.print(10 + leftX, 50 + leftY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + leftX, 50 + leftY + eventOffsetY, id(sub_sensor_font), "Kein Termin");
for (JsonVariant day_variant : calendar_days) {
JsonObject day = day_variant.as<JsonObject>();
JsonArray events = day["events"].as<JsonArray>();
if (events.isNull() || events.size() == 0) continue;
if (agenda_y + 38 > 345) {
has_hidden_events = true;
break;
}
// Arbeit today
if (id(kalender_heute_arbeit).has_state() && !id(kalender_heute_arbeit).state.empty()) {
it.print(10 + leftX, 85 + leftY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + leftX, 85 + leftY + eventOffsetY, id(sub_sensor_font), "%s",
id(kalender_heute_arbeit).state.substr(0, 60).c_str());
} else {
it.print(10 + leftX, 85 + leftY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + leftX, 85 + leftY + eventOffsetY, id(sub_sensor_font), "Kein Termin");
const int day_number = day["day"] | 0;
const char *weekday = day["weekday"] | "";
const bool is_today = (day["today"] | 0) == 1;
it.printf(30, agenda_y, id(sub_sensor_font), TextAlign::TOP_CENTER, "%d", day_number);
it.printf(30, agenda_y + 28, id(footer_font), TextAlign::TOP_CENTER, "%s", weekday);
it.print(68, agenda_y + 2, id(footer_font), TextAlign::TOP_LEFT, is_today ? "HEUTE" : "");
it.line(58, agenda_y, 58, agenda_y + 32 + events.size() * 35);
agenda_y += 36;
for (JsonVariant event_variant : events) {
if (agenda_y + 33 > 345) {
has_hidden_events = true;
break;
}
JsonObject event = event_variant.as<JsonObject>();
const char *title = event["title"] | "Ohne Titel";
const char *time = event["time"] | "";
const char *meta = event["meta"] | "";
it.printf(72, agenda_y, id(sensor_unit), TextAlign::TOP_LEFT, "%s", title);
it.printf(350, agenda_y, id(sensor_unit), TextAlign::TOP_RIGHT, "%s", time);
it.printf(72, agenda_y + 20, id(footer_font), TextAlign::TOP_LEFT, "%s", meta);
agenda_y += 35;
has_events = true;
}
agenda_y += 5;
if (has_hidden_events) break;
}
}
/* ── RIGHT PANE: Tomorrow ── */
int rightX = 315;
int rightY = 70;
it.print(45 + rightX, 10 + rightY, id(sensor_unit), "Morgen");
it.filled_rectangle(130 + rightX, 21 + rightY, 200, 3);
/* Date strip */
it.printf(50 + rightX, 50 + rightY, id(big_sensor_font), "%d", tomorrow_day);
it.printf(145 + rightX, 45 + rightY, id(sub_sensor_font), "%s.", tomorrow_weekday_str);
it.printf(205 + rightX, 45 + rightY, id(sensor_unit), "%02d.%04d.", tomorrow_month, tomorrow_year);
/* Event lines (Privat / Arbeit) */
// Privat tomorrow
if (id(kalender_morgen_privat).has_state() && !id(kalender_morgen_privat).state.empty()) {
it.print(10 + rightX, 50 + rightY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + rightX, 50 + rightY + eventOffsetY, id(sub_sensor_font), "%s",
id(kalender_morgen_privat).state.substr(0, 60).c_str());
} else {
it.print(10 + rightX, 50 + rightY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + rightX, 50 + rightY + eventOffsetY, id(sub_sensor_font), "Kein Termin");
if (!has_events && !calendar_error && !calendar_days.isNull() && calendar_days.size() > 0) {
it.print(18, 72, id(sensor_unit), TextAlign::TOP_LEFT, "Keine Termine im sichtbaren Bereich.");
}
// Arbeit tomorrow
if (id(kalender_morgen_arbeit).has_state() && !id(kalender_morgen_arbeit).state.empty()) {
it.print(10 + rightX, 85 + rightY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + rightX, 85 + rightY + eventOffsetY, id(sub_sensor_font), "%s",
id(kalender_morgen_arbeit).state.substr(0, 60).c_str());
} else {
it.print(10 + rightX, 85 + rightY + eventOffsetY, id(mdi_med), TextAlign::BASELINE_LEFT, "\U0001f32e" );
it.printf(40 + rightX, 85 + leftY + eventOffsetY, id(sub_sensor_font), "Kein Termin");
if (has_hidden_events) {
it.print(72, 340, id(footer_font), TextAlign::TOP_LEFT, "Weitere Termine vorhanden ...");
}
/* RIGHT TOP: month view, Monday-first with ISO week numbers */
char month_title[24];
snprintf(month_title, sizeof(month_title), "%s %d", months[month - 1], year);
it.printf(502, 18, id(sensor_unit), TextAlign::TOP_CENTER, "%s", month_title);
it.line(375, 28, 630, 28);
it.print(384, 47, id(footer_font), TextAlign::TOP_CENTER, "KW");
for (int column = 0; column < 7; column++) {
it.printf(415 + column * 30, 47, id(footer_font), TextAlign::TOP_CENTER, "%s", weekdays[column]);
}
const int first_weekday = weekday_monday(year, month, 1);
const int month_days = days_in_month(year, month);
for (int row = 0; row < 6; row++) {
const int monday_day = 1 - first_weekday + row * 7;
int week_year = year;
int week_month = month;
int week_day = monday_day;
if (week_day < 1) {
week_month--;
if (week_month == 0) {
week_month = 12;
week_year--;
}
week_day += days_in_month(week_year, week_month);
} else if (week_day > month_days) {
week_day -= month_days;
week_month++;
if (week_month == 13) {
week_month = 1;
week_year++;
}
}
const int cell_y = 69 + row * 23;
it.printf(384, cell_y, id(footer_font), TextAlign::TOP_CENTER, "%02d", iso_week(week_year, week_month, week_day));
for (int column = 0; column < 7; column++) {
const int day = row * 7 + column - first_weekday + 1;
if (day < 1 || day > month_days) continue;
const int cell_x = 415 + column * 30;
if (day == today) {
it.filled_rectangle(cell_x - 12, cell_y - 2, 25, 18, Color::BLACK);
it.printf(cell_x, cell_y, id(footer_font), Color::WHITE, TextAlign::TOP_CENTER, "%d", day);
} else {
it.printf(cell_x, cell_y, id(footer_font), TextAlign::TOP_CENTER, "%d", day);
}
}
}
/* RIGHT BOTTOM: quote placeholder, intentionally inverted */
it.filled_rectangle(375, 220, 255, 130, Color::BLACK);
it.print(502, 234, id(footer_font), Color::WHITE, TextAlign::TOP_CENTER, "DEMOTIVATION");
it.print(502, 267, id(sensor_unit), Color::WHITE, TextAlign::TOP_CENTER, "Es ist nie zu spät,");
it.print(502, 291, id(sensor_unit), Color::WHITE, TextAlign::TOP_CENTER, "die Erwartungen zu senken.");
it.print(502, 326, id(footer_font), Color::WHITE, TextAlign::TOP_CENTER, "Zitatquelle folgt");
/* FOOTER */
it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT, "Aktualisiert um %d.%m.%Y %H:%M", id(homeassistant_time).now());
/* WiFi Signal strength */
if(id(wifisignal).has_state()) {
int x = 630;
int y = 384;
if (id(wifisignal).state >= -50) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤨");
} else if (id(wifisignal).state >= -60) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤥");
} else if (id(wifisignal).state >= -75) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤢");
} else if (id(wifisignal).state >= -100) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤟");
} else {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤫");
}
}
- id: power
lambda: |-
float total_power = id(power_total).state;
float serverroom_power = id(power_serverroom).state;
float livingroom_desk = id(desk_livingroom).state;
float livingroom_media = id(media_livingroom).state;
float sleepingroom = id(media_sleepingroom).state + id(bedlight_sleepingroom).state;
int offsetX = 0;
int offsetY = 0;
/* BASEMENT */
it.print(10, 10, id(sensor_unit), "Keller");
/*
Draw the outline of a rectangle with the top left at [86,21],
a width of 297 and a height of 3
*/
it.filled_rectangle(76, 21, 307, 3);
/* C1024 logo */
it.image(10 , 37, id(c1024_logo));
/* Livingroom */
offsetY = 127;
it.print(10, 10 + offsetY, id(sensor_unit), "Wohnzimmer");
it.filled_rectangle(136, 21 + offsetY, 247, 3);
it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰚥"); // power-plug
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰚥"); // power-plug
it.print(20, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_LEFT, "Schreibtisch");
if(livingroom_desk >= 0) {
it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f W", livingroom_desk);
}
else {
it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W");
}
it.print(20, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_LEFT, "Heimkino");
if(livingroom_media >= 0) {
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f W", livingroom_media);
}
else {
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W");
}
/* Sleepingroom */
offsetY = 247;
it.print(10, 10 + offsetY, id(sensor_unit), "Schlafzimmer");
it.filled_rectangle(144, 21 + offsetY, 239, 3);
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰚥"); // power-plug
// it.print(20, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_LEFT, "Heimkino");
if(sleepingroom >= 0) {
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f W", sleepingroom);
}
else {
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W");
}
/* LINEPOWER */
offsetX = 390;
offsetY = 65;
it.print(10 + offsetX, 10, id(sensor_unit), "Gesamt");
it.filled_rectangle(90 + offsetX, 21, 155, 3);
it.print(227 + offsetX, 20 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰴾"); // transmission-tower
if(total_power >= 0) {
it.printf(207 + offsetX, 20 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "W");
it.printf(170 + offsetX, 20 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f", total_power);
}
else {
it.print(207 + offsetX, 20 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W");
}
it.graph(10 + offsetX, 30 + offsetY, id(line_power_graph));
/* Serverroom */
offsetY = 247;
it.print(10 + offsetX, 10 + offsetY, id(sensor_unit), "Serverraum");
it.filled_rectangle(125 + offsetX, 21 + offsetY, 110, 3);
it.print(227 + offsetX, 110 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰚥"); // power-plug
if(serverroom_power >= 0) {
it.printf(207 + offsetX, 110 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "W");
it.printf(170 + offsetX, 110 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f", serverroom_power);
}
else {
it.print(207 + offsetX, 110 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W");
}
/* FOOTER */
it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT , "Aktualisiert um %d.%m.%Y %H:%M", id(homeassistant_time).now());
/* WiFi Signal strength */
if(id(wifisignal).has_state()) {
int x = 630;
int y = 384;
if (id(wifisignal).state >= -50) {
// Excellent
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤨");
ESP_LOGI("WiFi", "Excellent");
} else if (id(wifisignal).state >= -60) {
// Good
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤥");
ESP_LOGI("WiFi", "Good");
} else if (id(wifisignal).state >= -75) {
// Fair
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤢");
ESP_LOGI("WiFi", "Fair");
} else if (id(wifisignal).state >= -100) {
// Weak
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤟");
ESP_LOGI("WiFi", "Weak");
} else {
// Unlikely working signal
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤫");
ESP_LOGI("WiFi", "Unlikely");
}
}
it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT,
"Aktualisiert um %d.%m.%Y %H:%M", now);
+84
View File
@@ -0,0 +1,84 @@
# Calendar data is compacted here so the ESP32 only receives display-ready entries.
CALENDAR_NAMES = {
"calendar.tkrz_kalender": "Arbeit",
"calendar.privat": "Privat",
}
DAY_NAMES = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
MAX_ENTRIES = 8
MAX_TITLE_LENGTH = 28
MAX_META_LENGTH = 32
def shorten(value, maximum):
value = (value or "").strip()
if len(value) <= maximum:
return value
return value[: maximum - 3].rstrip() + "..."
def compact_event(event, calendar_name):
start = event.get("start", "")
all_day = "T" not in start
time = "ganztägig" if all_day else start[11:16]
location = (event.get("location") or "").split("\n")[0].strip()
meta = calendar_name
if location:
meta += " / " + location
return {
"title": shorten(event.get("summary", "Ohne Titel"), MAX_TITLE_LENGTH),
"time": time,
"meta": shorten(meta, MAX_META_LENGTH),
"all_day": int(all_day),
}
calendar_data = data.get("calendar", {})
today = str(data.get("now", ""))[:10]
events_by_date = {}
for calendar_id, calendar in calendar_data.items():
calendar_name = CALENDAR_NAMES.get(calendar_id, calendar_id.split(".")[-1].capitalize())
for event in calendar.get("events", []):
start = event.get("start", "")
end = event.get("end", "")
event_date = start[:10]
end_date = end[:10]
# Ignore malformed or already finished entries. All-day event end dates
# are exclusive in Home Assistant; timed events ending today may still be
# active. Multi-day entries remain visible on today's date rail.
all_day = "T" not in start
if not event_date or (all_day and end_date <= today) or (not all_day and end_date < today):
continue
if event_date < today:
event_date = today
events_by_date.setdefault(event_date, []).append(
compact_event(event, calendar_name)
)
entries = []
entry_count = 0
for date in sorted(events_by_date):
if entry_count >= MAX_ENTRIES:
break
events = events_by_date[date]
events.sort(key=lambda item: (item["all_day"] == 0, item["time"]))
remaining = MAX_ENTRIES - entry_count
events = events[:remaining]
entry_count += len(events)
parsed_date = dt_util.parse_datetime(date)
entries.append(
{
"day": parsed_date.day,
"weekday": DAY_NAMES[parsed_date.weekday()],
"today": int(date == today),
"events": events,
}
)
output["entries"] = entries
+30 -27
View File
@@ -49,6 +49,7 @@
name: Sun Setting Template
state: '{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom
(''%H:%M'') }}'
- name: "power_other"
unique_id: '5579422933393'
unit_of_measurement: "W"
@@ -79,6 +80,35 @@
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
# Compact calendar feed for the e-paper display. The actual event data lives in
# the `entries` attribute, which ESPHome reads as a text sensor.
- trigger:
- trigger: homeassistant
event: start
- trigger: time_pattern
minutes: /15
action:
- action: calendar.get_events
target:
entity_id:
- calendar.tkrz_kalender
- calendar.privat
data:
duration:
days: 14
response_variable: calendar_response
- action: python_script.epaper_calendar_data
data:
calendar: "{{ calendar_response }}"
now: "{{ now().date() }}"
response_variable: calendar_converted
sensor:
- name: Epaper Kalenderdaten
unique_id: epaper_calendar_data
state: "{{ calendar_converted.entries | count }}"
attributes:
entries: "{{ calendar_converted.entries }}"
# Shelly 3EM cumulative sensors (incl. PV)
- sensor:
# Template sensor for values of power import (active_power > 0)
@@ -145,30 +175,3 @@
unit_of_measurement: 'Mbps'
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
# ── Kalender-Ereignisse für epaperframe ──
# Alle Events werden per Automation (automations.yaml) in input_text Helfer geschrieben.
# Diese template sensors lesen nur noch daraus. Das verhindert doppelte Logik und garantiert,
# dass sowohl "heute" als auch "morgen" Events mit Titeln, Uhrzeiten und Beschreibungen verfügbar sind.
- sensor:
# ── HEUTE ──
- name: "Kalender heute Privat"
unique_id: kalender_heute_privat
state: "{{ states('input_text.kalender_heute_privat') }}"
icon: mdi:calendar-account
- name: "Kalender heute Arbeit"
unique_id: kalender_heute_arbeit
state: "{{ states('input_text.kalender_heute_arbeit') }}"
icon: mdi:calendar-account
# ── MORGEN ──
- name: "Kalender morgen Privat"
unique_id: kalender_morgen_privat
state: "{{ states('input_text.kalender_morgen_privat') }}"
icon: mdi:calendar-calendar-today
- name: "Kalender morgen Arbeit"
unique_id: kalender_morgen_arbeit
state: "{{ states('input_text.kalender_morgen_arbeit') }}"
icon: mdi:calendar-calendar-today
-20
View File
@@ -1,20 +0,0 @@
kalender_heute_privat:
name: "Kalender heute Privat"
initial: "-"
icon: mdi:calendar-account
mode: text
kalender_heute_arbeit:
name: "Kalender heute Arbeit"
initial: "-"
icon: mdi:calendar-account
mode: text
kalender_morgen_privat:
name: "Kalender morgen Privat"
initial: "-"
icon: mdi:calendar-calendar-today
mode: text
kalender_morgen_arbeit:
name: "Kalender morgen Arbeit"
initial: "-"
icon: mdi:calendar-calendar-today
mode: text