Ich habe mir über Amazon auch das Waveshare 7.5’ Display besorgt und nach einigen Anlaufschwierigkeiten zum Laufen gebracht. Allerdings habe ich immer noch ein großes Problem: direkt nach dem Start zeigt das Display den Inhalt mit schönem Kontrast an, der verblasst allerdings bei jeder neuen Nachricht, die an das Display geschickt wird, bis es irgendwann nicht mehr lesbar ist. Ich habe mehrere Modelle im Code ausprobiert, bin dann beim Modell 7.50inv2alt (wie auch schon von Euch erwähnt) hängen geblieben - das hatte direkt nach dem Start den besten Kontrast. Die Stromversorgung sollte nicht das Problem sein: das Teil hängt an einem USB-Netzteil mit 5V/2A.
Ich habe die folgende Konfiguration:
esphome:
name: epaper_notification
friendly_name: ePaper
esp32:
board: esp32dev
ota:
platform: esphome
password: "xxxxx"
api:
encryption:
key: "xxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: True
power_save_mode: NONE
manual_ip:
static_ip: xxxxx
gateway: xxxxx
subnet: xxxxx
ap:
ssid: "Epaper-Notification"
password: "xxxxxx"
logger:
level: WARN
spi:
clk_pin: GPIO13
mosi_pin: GPIO14
font:
- file: "fonts/arial.ttf"
id: my_font
size: 24
glyphs: [
' ', '!', ',', '.', '&', '(', ')', '*', '-', ':', '>', '<', ';', '=', '?', '[', ']', '~', '/', '%', '€', '$', '"',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü', 'ß'
]
globals:
- id: notif_queue
type: std::deque<std::string>
restore_value: no
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: homeassistant
id: epaper_notification
entity_id: input_text.epaper_notification
on_value:
then:
- lambda: |-
ESP_LOGD("custom", "epaper_notification changed");
auto new_entry = id(epaper_notification).state.c_str();
ESP_LOGD("custom", "New entry: %s", new_entry);
if (strlen(new_entry) > 0) {
ESP_LOGD("custom", "New entry length: %d", strlen(new_entry));
// Aktuelle Zeit abrufen und formatieren (KORREKT!)
auto now = id(homeassistant_time).now();
char timestamp[16];
snprintf(timestamp, sizeof(timestamp), "%02d:%02d ", now.hour, now.minute); // Formatierung direkt mit snprintf
// Nachricht mit Zeitstempel kombinieren
std::string message_with_time = std::string(timestamp) + std::string(new_entry);
if (id(notif_queue).size() >= 10) {
id(notif_queue).pop_front();
ESP_LOGD("custom", "Notif queue full, oldest entry removed");
}
id(notif_queue).push_back(message_with_time);
ESP_LOGD("custom", "New entry added to notif_queue");
}
id(epaper_display).update();
ESP_LOGD("custom", "Display update triggered");
- platform: homeassistant
id: ha_notification # ID hinzugefügt!
entity_id: sensor.nachster_abholtermin
on_value:
then:
- lambda: |-
ESP_LOGD("custom", "Update triggered by ha_notification");
id(epaper_display).update();
display:
- platform: waveshare_epaper
id: epaper_display
cs_pin: GPIO15
dc_pin: GPIO27
busy_pin:
number: GPIO25
inverted: true
reset_pin: GPIO26
reset_duration: 2ms
model: 7.50inv2alt
rotation: 0
update_interval: 60s
lambda: |-
it.fill(COLOR_OFF);
it.printf(400, 20, id(my_font), COLOR_ON, TextAlign::CENTER, "Die letzten Home Assistant Benachrichtigungen:");
it.horizontal_line(0, 46, 800, COLOR_ON);
int y_offset = 60;
for (const auto& entry : id(notif_queue)) { // Korrektur: Range-based for loop!
if (!entry.empty()) {
it.printf(10, y_offset, id(my_font), COLOR_ON, "%s", entry.c_str());
y_offset += 30;
if (y_offset > 400) break;
}
}
it.horizontal_line(0, 434, 800, COLOR_ON);
std::string sensor_text = id(ha_notification).state.c_str();
it.printf(400, 460, id(my_font), COLOR_ON, TextAlign::CENTER, "%s", sensor_text.c_str());
Die Idee war: Oben eine Überschrift, darunter eine Linie. Am unteren Rand die Anzeige der nächsten Müll-Abholtermine, darüber eine Linie. Dazwischen der “dynamische” Bereich für Notifications von Home Assistant. Die neueste immer oben, und die letzte (die 10. oder 11.) verschwindet dann wieder. Also immer so, dass auf dem Display die letzten 10 Notifications von oben nach unten zu sehen sind.
Ich habe schon mit mehreren Parametern gespielt: update_interval, epaper_display.update, restore_value, und so weiter. Alles ohne Änderung am Display-Verhalten. Ich sehe zwar, dass das Display regelmäßig einen kompletten Refresh macht (invertiert von schwarz auf weiß zu weiß auf schwarz für ganz kurze Zeit - weiß auf schwarz sieht vom Kontrast her sehr gut aus…), aber danach ist der Text wieder total blass.
Habt Ihr Ideen?