Hi,
I am having an issue getting my epaper display to work properly.
I am trying to just get date calendar to print , it showed me last night “No data available” , but then I went to bed, and this morning I found that it is showing me the proper calendar date. My thinking is that when I deploy the code to it, it doesn’t get the values from home assistant right away so values are empty, but it gets values few seconds after it refresh the screen. Later on, when screen refresh it grabs the values. Is there a way to make sure the values refresh when I deploy the code? it is making it hard for me to troubleshoot and continue dev on it without seeing the results right away.
This is my code (I tried to add a screen update on value, but it isn’t working)
esphome:
name: "mycalendar"
platform: esp32
board: esp32dev
on_boot:
priority: 600
then:
- script.execute: update_screen #
- delay: 15s # Add a small delay to ensure all sensors are ready
- script.execute: update_screen # Trigger again to ensure update
# Wi-Fi configuration
wifi:
ssid: "ddar4"
password: "xxxx"
ap:
ssid: "esphomeddar4"
password: "xxxx"
# Enable logging, API, and OTA updates
logger:
api:
encryption:
key: "xxxxx"
ota:
platform: esphome
script:
- id: update_screen
then:
- component.update: eink_display
time:
- platform: sntp
id: sntp_time
on_time:
- seconds: 0
minutes: 0
hours: 0
then:
- script.execute: update_screen # ✅ Refresh at midnight
- seconds: 0
minutes: 0
hours: 8
days_of_week: MON-SUN
then:
- script.execute: update_screen # ✅ Refresh every morning
- seconds: 0
minutes: 0
hours: 16
then:
- script.execute: update_screen # ✅ Refresh in the afternoon
spi:
clk_pin: 13
mosi_pin: 14
font:
- file: "fonts/GothamRnd-Book.ttf"
id: book20
size: 20
- file: "fonts/GothamRnd-Book.ttf"
id: book25
size: 25
- file: "fonts/GothamRnd-Bold.ttf"
id: bold20
size: 20
- file: "fonts/GothamRnd-Bold.ttf"
id: bold30
size: 30
- file: "fonts/GothamRnd-Bold.ttf"
id: bold40
size: 40
text_sensor:
# Date from Home Assistant
- platform: homeassistant
entity_id: sensor.current_day_name
id: current_day_name
on_value:
then:
- script.execute: update_screen
- platform: homeassistant
entity_id: sensor.current_day_number
id: current_day_number
on_value:
then:
- script.execute: update_screen
- platform: homeassistant
entity_id: sensor.current_month
id: current_month
on_value:
then:
- script.execute: update_screen
# Calendar Events
- platform: homeassistant
entity_id: sensor.esp_calendar_data
attribute: event_title_1
id: event_title_1
- platform: homeassistant
entity_id: sensor.esp_calendar_data
attribute: event_start_1
id: event_start_1
- platform: homeassistant
entity_id: sensor.esp_calendar_data
attribute: event_title_2
id: event_title_2
- platform: homeassistant
entity_id: sensor.esp_calendar_data
attribute: event_start_2
id: event_start_2
display:
- platform: waveshare_epaper
id: eink_display
cs_pin: 15
dc_pin: 27
busy_pin: 25
reset_pin: 26
reset_duration: 2ms
model: 7.50inv2
rotation: 270°
update_interval: never
lambda: |-
ESP_LOGI("display", "Updating ePaper Calendar...");
it.fill(Color(0, 0, 0));
if (id(current_day_name).has_state() &&
id(current_day_number).has_state() &&
id(current_month).has_state()) {
std::string formatted_date = id(current_day_name).state + " " +
id(current_day_number).state + " " +
id(current_month).state;
ESP_LOGI("display", "Formatted Date: %s", formatted_date.c_str());
it.printf(240, 40, id(bold30), TextAlign::CENTER, "%s", formatted_date.c_str());
} else {
ESP_LOGE("display", "Date sensors missing!");
it.printf(240, 40, id(bold30), TextAlign::CENTER, "No Date Available");
}
// Step 2: Draw a Horizontal Line
it.filled_rectangle(50, 90, 380, 2);