Fetch data from api and present it on a display fails

Hello,

I’m struggling to get data from HomeAssistant native API and present on my e-paper display - What I’m doing wrong here?
It results in compile error: error: no matching function for call to 'esphome::display::DisplayBuffer::print(int, int, esphome::display::Font*&, std::__cxx11::string&)'

display:
  - platform: waveshare_epaper
    rotation: 90
    cs_pin: GPIO26
    dc_pin: GPIO25
    busy_pin: GPIO27
    reset_pin: GPIO33
    model: 2.90inv2
    full_update_every: 30
    lambda: |-
        it.print(30, 10, id(my_font), "Klingelschild");
        it.print(10, 60, id(my_font_small), id(outdoor_bell_additional_info_top));
        it.print(10, 80, id(my_font_small), "Bitte Paket abstellen!");
        it.print(10, 80, id(my_font_small), "Zusatzinfo");
        
text_sensor:
  - platform: homeassistant
    name: "outdoor_bell_additional_info_top"
    entity_id: input_text.outdoor_bell_additional_info_top
    id: outdoor_bell_additional_info_top

You have to add “.state”

    it.print(10, 60, id(my_font_small), id(outdoor_bell_additional_info_top).state);

I also tried that. That produces:

/config/esphome/outdoor-bell.yaml: In lambda function:
/config/esphome/outdoor-bell.yaml:58:78: error: no matching function for call to 'esphome::display::DisplayBuffer::print(int, int, esphome::display::Font*&, std::__cxx11::string&)'
         it.print(10, 60, id(my_font_small), id(outdoor_bell_additional_info_top).state);

Can you post your complete yaml file.

esphome:
  name: outdoor_bell
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "TRUDI_IOT"
  password: "censored"
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.2.65
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.2.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Outdoor Bell Fallback Hotspot"
    password: "censored"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "censored"

ota:
  password: "censored"
  
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  
font:
  - file: "fonts/BreeSerif-Regular.ttf"
    id: my_font
    size: 35

  - file: "fonts/BreeSerif-Regular.ttf"
    id: my_font_small
    size: 18
    
display:
  - platform: waveshare_epaper
    rotation: 90
    cs_pin: GPIO26
    dc_pin: GPIO25
    busy_pin: GPIO27
    reset_pin: GPIO33
    model: 2.90inv2
    full_update_every: 30
    lambda: |-
        it.print(30, 10, id(my_font), "Klingelschild");
        it.print(10, 60, id(my_font_small), id(outdoor_bell_additional_info_top).state);
        it.print(10, 80, id(my_font_small), "Bitte Paket abstellen!");
        it.print(10, 80, id(my_font_small), "Zusatzinfo");
        
text_sensor:
  - platform: homeassistant
    name: "outdoor_bell_additional_info_top"
    entity_id: input_text.outdoor_bell_additional_info_top
    id: outdoor_bell_additional_info_top

Enter also a ".c_str() after “.state”

Thanks so much! It’s working :slight_smile: