esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Cant update ESPHome for waveshare display #5195

Closed 1liminal1 closed 9 months ago

1liminal1 commented 9 months ago

The problem

I understand there was an breaking changes in 2023.6 for fonts ect. But its really not clear how to fix this?

I have pasted my YAML and the compile errors, but please let me know if anything else is needed :)

Thank you

Which version of ESPHome has the issue?

2023.11.6

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.11.3

What platform are you using?

ESP32

Board

Dev Board

Component causing the issue

Not sure

Example YAML snippet

# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!)
globals:
  - id: data_updated
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: initial_data_received
    type: bool
    restore_value: no
    initial_value: 'false'

external_components:
  - source:
      type: git
      url: https://github.com/guardmedia/esphome.git
      ref: waveshare-color-5
    components: [ waveshare_epaper, display ]

# Include custom fonts
font:
  - file: fonts/materialdesignicons-webfont.ttf
    id: icon_font
    size: 50
    glyphs:
      - "\U000F0590" # weather-cloudy
      - "\U000F0F2F" # weather-cloudy-alert
      - "\U000F0E6E" # weather-cloudy-arrow-right
      - "\U000F0591" # weather-fog
      - "\U000F0592" # weather-hail
      - "\U000F0F30" # weather-hazy
      - "\U000F0898" # weather-hurricane
      - "\U000F0593" # weather-lightning
      - "\U000F067E" # weather-lightning-rainy
      - "\U000F0594" # weather-night
      - "\U000F0F31" # weather-night-partly-cloudy
      - "\U000F0595" # weather-partly-cloudy
      - "\U000F0F32" # weather-partly-lightning
      - "\U000F0F33" # weather-partly-rainy
      - "\U000F0F34" # weather-partly-snowy
      - "\U000F0F35" # weather-partly-snowy-rainy
      - "\U000F0596" # weather-pouring
      - "\U000F0597" # weather-rainy
      - "\U000F0598" # weather-snowy
      - "\U000F0F36" # weather-snowy-heavy
      - "\U000F067F" # weather-snowy-rainy
      - "\U000F0599" # weather-sunny
      - "\U000F0F37" # weather-sunny-alert
      - "\U000F14E4" # weather-sunny-off
      - "\U000F059A" # weather-sunset
      - "\U000F059B" # weather-sunset-down
      - "\U000F059C" # weather-sunset-up
      - "\U000F0F38" # weather-tornado
      - "\U000F059D" # weather-windy
      - "\U000F059E" # weather-windy-variant
      - "\U000F050F" # mdi-thermometer   
      - "\U000F18D7" # sun-thermometer-outline    
      - "\U000F0F55" # home-thermometer-outline                  

  - file: 'fonts/GothamRnd-Bold.ttf'
    id: font_title
    size: 40
    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', '/','[', ']',"'"]

  - file: 'fonts/GothamRnd-Bold.ttf'
    id: font_small_bold
    size: 25
    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', '/','[', ']',"'"]

# Check whether the display needs to be refreshed every minute,
# based on whether new data is received or motion is detected. (Thanks @paviro!)
time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      - seconds: 0
        minutes: /1
        then:
          - if:
              condition:
                lambda: 'return id(data_updated) == true;'
              then:
                - lambda: 'id(initial_data_received) = true;'
                - if:
                    condition:
                      binary_sensor.is_on: motion_detected
                    then:
                      - logger.log: "Sensor data updated and activity in home detected: Refreshing display..."
                - component.update: eink_display
                - lambda: 'id(data_updated) = false;'
              else:
                      - logger.log: "Sensor data updated but no activity in home - skipping display refresh."
  - platform: sntp
    id: ntp
    timezone: Australia/Sydney
    servers:
      - 0.pool.ntp.org
      - 1.pool.ntp.org
      - 2.pool.ntp.org

# Check if motion is detected in the bathroom.
binary_sensor:
  - platform: homeassistant
    entity_id: binary_sensor.bathroom_motion_sensor
    id: motion_detected       

# Call calender sensors from HA.
text_sensor:
  - platform: homeassistant
    entity_id: sensor.esphome_to_do
    id: alexa_to_do_list
    on_value:
      then:
         - lambda: 'id(data_updated) = true;'

  - platform: homeassistant
    entity_id: sensor.epshome_shopping_list
    id: alexa_shopping_list
    on_value:
      then:
         - lambda: 'id(data_updated) = true;'

  - platform: homeassistant
    name: "Today Weather"
    entity_id: weather.home
    id: weather_icon
    internal: true      

sensor:
  - platform: homeassistant
    entity_id: sensor.mascot_temp
    id: weather_temperature
    on_value:
      then:
        - lambda: 'id(data_updated) = true;'         

  - platform: homeassistant
    entity_id: sensor.bedroom_temperature
    id: bedroom_temp     
    on_value:
      then:
        - lambda: 'id(data_updated) = true;'         

# Define colors
# This design is white on black so this is necessary.
color:
  - id: color_black
    red: 0%
    green: 0%
    blue: 0%
    white: 100%
  - id: color_white
    red: 0%
    green: 0%
    blue: 0%
    white: 0%
  - id: color_red
    red: 100%
    green: 0%
    blue: 0%
    white: 0%    

# Pins for Waveshare ePaper ESP Board
spi:
  clk_pin: GPIO13
  mosi_pin: GPIO14

# Now render everything on the ePaper screen.
display:
  - platform: waveshare_epaper
    id: eink_display
    cs_pin: GPIO15
    dc_pin: GPIO27
    busy_pin: GPIO25
    reset_pin: GPIO26
    reset_duration: 2ms
    model: 7.50in-bV2
    update_interval: 1h
    rotation: 90°
    lambda: |-

      // Fill background.
      // it.fill(color_bg);

      // Show loading screen before data is received.
      if (id(initial_data_received) == false) {
        it.printf(215, 250, id(font_title), color_red, TextAlign::TOP_CENTER, "Just wait a second");
        it.printf(215, 350, id(font_title), color_red, TextAlign::TOP_CENTER, "It's still loading");
      } else {

        int time = id(ntp).now().hour * 100 + id(ntp).now().minute;

        if (id(weather_icon).has_state()) {
            std::map<std::string, std::string> weather_state { 
                { "sunny", "\U000F0599" },             // mdi:weather-sunny
                { "clear-night", "\U000F0594" },       // mdi:weather-night
                { "cloudy", "\U000F0590"},             // mdi:weather-cloudy
                { "rainy", "\U000F0597" },             // mdi:weather-pouring
                { "windy", "\U000F059D" },             // mdi:weather-windy-variant
                { "fog", "\U000F0591" },               // mdi:weather-fog
                { "partlycloudy", "\U000F0595" },      // mdi:weather-partly-cloudy
            };
          if (time < 1900) {
              it.printf(20, 90, id(icon_font), TextAlign::BASELINE_LEFT, weather_state[id(weather_icon).state.c_str()].c_str());
          } else {
              it.printf(20, 90, id(icon_font), TextAlign::BASELINE_LEFT, weather_state[id(weather_icon).state.c_str()].c_str());
          }
        }

        // Outside Temp
        it.printf(80, 90, id(icon_font), TextAlign::BASELINE_LEFT, "\U000F18D7"); 
        it.printf(135, 85, id(font_title), color_red, TextAlign::BASELINE_LEFT, "%2.0f°", id(weather_temperature).state);        

        // Inside Temp
        it.printf(240, 90, id(icon_font), TextAlign::BASELINE_LEFT, "\U000F0F55");    
        it.printf(295, 85, id(font_title), color_red, TextAlign::BASELINE_LEFT, "%2.0f°", id(bedroom_temp).state);        

        // To Do List
        it.printf(20, 140, id(font_title), color_red, TextAlign::BASELINE_LEFT, "To Do List");
        it.line(240, 127, 480, 127);

        std::string str1 = id(alexa_to_do_list).state; 

          // Display position and line height
          int xPos1 = 20, yPos1 = 160, lineHeight1 = 25;

        // Split into lines where comma+space is delimiter
        std::string delimiter1 = ", ";
        std::size_t curPos1 = 0, commaPos1 = 0;
        while (commaPos1 != std::string::npos) {
            commaPos1 = str1.find(delimiter1, curPos1);
            it.print(xPos1, yPos1, id(font_small_bold), str1.substr(curPos1, commaPos1 - curPos1).c_str());
            yPos1 += lineHeight1;
            curPos1 = commaPos1 + delimiter1.size();
        }             

        // Shopping List
        it.printf(20, 408, id(font_title), color_red, TextAlign::BASELINE_LEFT, "Shopping List");
        it.line(320, 395, 480, 395);  

        std::string str = id(alexa_shopping_list).state; 

          // Display position and line height
          int xPos = 20, yPos = 430, lineHeight = 25;

        // Split into lines where comma+space is delimiter
        std::string delimiter = ", ";
        std::size_t curPos = 0, commaPos = 0;
        while (commaPos != std::string::npos) {
            commaPos = str.find(delimiter, curPos);
            it.print(xPos, yPos, id(font_small_bold), str.substr(curPos, commaPos - curPos).c_str());
            yPos += lineHeight;
            curPos = commaPos + delimiter.size();
        }       

        // FOOTER
        //Divider draw a line from [x=0,y=0] to [x=50,y=50]
        it.line(0, 665, 480, 665);
        // Show date and time of last update          
        it.strftime(215, 700, id(font_small_bold), TextAlign::BASELINE_CENTER, "Updated: %Y-%m-%d  %H:%M", id(ntp).now());
      };

captive_portal:

Anything in the logs that might be useful for us?

In file included from src/esphome/components/font/font.h:5,
                 from src/esphome/components/font/font.cpp:1:
src/esphome/components/display/display_buffer.h:248:99: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, Color color, TextAlign align, const char *format, time::ESPTime time)
                                                                                                   ^~~~~~~
src/esphome/components/display/display_buffer.h:260:82: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, Color color, const char *format, time::ESPTime time)
                                                                                  ^~~~~~~
src/esphome/components/display/display_buffer.h:272:86: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, TextAlign align, const char *format, time::ESPTime time)
                                                                                      ^~~~~~~
src/esphome/components/display/display_buffer.h:283:69: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, const char *format, time::ESPTime time)
                                                                     ^~~~~~~
In file included from src/esphome/components/font/font.cpp:1:
src/esphome/components/font/font.h:25:36: error: 'esphome::display::Display' has not been declared
   void draw(int x, int y, display::Display *display, Color color) const;
                                    ^~~~~~~
src/esphome/components/font/font.h:41:39: error: expected class-name before '{' token
 class Font : public display::BaseFont {
                                       ^
src/esphome/components/font/font.h:53:49: error: 'esphome::display::Display' has not been declared
   void print(int x_start, int y_start, display::Display *display, Color color, const char *text) override;
                                                 ^~~~~~~
src/esphome/components/font/font.h:53:8: error: 'void esphome::font::Font::print(int, int, int*, esphome::Color, const char*)' marked 'override', but does not override
   void print(int x_start, int y_start, display::Display *display, Color color, const char *text) override;
        ^~~~~
src/esphome/components/font/font.h:54:8: error: 'void esphome::font::Font::measure(const char*, int*, int*, int*, int*)' marked 'override', but does not override
   void measure(const char *str, int *width, int *x_offset, int *baseline, int *height) override;
        ^~~~~~~
src/esphome/components/font/font.cpp:13:50: error: 'esphome::display::Display' has not been declared
 void Glyph::draw(int x_at, int y_start, display::Display *display, Color color) const {
                                                  ^~~~~~~
src/esphome/components/font/font.cpp: In member function 'void esphome::font::Glyph::draw(int, int, int*, esphome::Color) const':
src/esphome/components/font/font.cpp:28:20: error: request for member 'draw_pixel_at' in '* display', which is of non-class type 'int'
           display->draw_pixel_at(pixel_x, glyph_y, color);
                    ^~~~~~~~~~~~~
src/esphome/components/font/font.cpp: At global scope:
src/esphome/components/font/font.cpp:121:53: error: 'esphome::display::Display' has not been declared
 void Font::print(int x_start, int y_start, display::Display *display, Color color, const char *text) {
                                                     ^~~~~~~
src/esphome/components/font/font.cpp: In member function 'void esphome::font::Font::print(int, int, int*, esphome::Color, const char*)':
src/esphome/components/font/font.cpp:132:18: error: request for member 'filled_rectangle' in '* display', which is of non-class type 'int'
         display->filled_rectangle(x_at, y_start, glyph_width, this->height_, color);
                  ^~~~~~~~~~~~~~~~
In file included from src/esphome/components/display/display_buffer.cpp:1:
src/esphome/components/display/display_buffer.h:248:99: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, Color color, TextAlign align, const char *format, time::ESPTime time)
                                                                                                   ^~~~~~~
src/esphome/components/display/display_buffer.h:260:82: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, Color color, const char *format, time::ESPTime time)
                                                                                  ^~~~~~~
src/esphome/components/display/display_buffer.h:272:86: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, TextAlign align, const char *format, time::ESPTime time)
                                                                                      ^~~~~~~
src/esphome/components/display/display_buffer.h:283:69: error: 'esphome::time::ESPTime' has not been declared
   void strftime(int x, int y, Font *font, const char *format, time::ESPTime time)
                                                                     ^~~~~~~
*** [.pioenvs/to-do/src/esphome/components/font/font.cpp.o] Error 1
src/esphome/components/display/display_buffer.cpp:378:36: error: 'esphome::time::ESPTime' has not been declared
                              time::ESPTime time) {
                                    ^~~~~~~
src/esphome/components/display/display_buffer.cpp: In member function 'void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::Color, esphome::display::TextAlign, const char*, int)':
src/esphome/components/display/display_buffer.cpp:380:21: error: request for member 'strftime' in 'time', which is of non-class type 'int'
   size_t ret = time.strftime(buffer, sizeof(buffer), format);
                     ^~~~~~~~
src/esphome/components/display/display_buffer.cpp: At global scope:
src/esphome/components/display/display_buffer.cpp:384:95: error: 'esphome::time::ESPTime' has not been declared
 void DisplayBuffer::strftime(int x, int y, Font *font, Color color, const char *format, time::ESPTime time) {
                                                                                               ^~~~~~~
src/esphome/components/display/display_buffer.cpp:387:99: error: 'esphome::time::ESPTime' has not been declared
 void DisplayBuffer::strftime(int x, int y, Font *font, TextAlign align, const char *format, time::ESPTime time) {
                                                                                                   ^~~~~~~
src/esphome/components/display/display_buffer.cpp:390:82: error: 'esphome::time::ESPTime' has not been declared
 void DisplayBuffer::strftime(int x, int y, Font *font, const char *format, time::ESPTime time) {
                                                                                  ^~~~~~~
*** [.pioenvs/to-do/src/esphome/components/display/display_buffer.cpp.o] Error 1
========================== [FAILED] Took 5.11 seconds ===================

Additional information

No response

ssieb commented 9 months ago

github issues are not for external components. Come ask on discord.

1liminal1 commented 9 months ago

Thats what it was :) :) thank you so much!

I have no idea if the screen works lol, will have to check when I get home. But remove that (the link is 404, might be gone) and I could update thanks again