Esphome gpio.switch status on OLED display

Look at Display Component — ESPHome

# Bad code
it.printf(2, 10, id(roboto), id(ip_addr->toString()));
# OK 
it.printf(2, 10, id(roboto),"IP: %s" , id(ip_addr).state.c_str());

Thanks @Miki_Spetik

I think now I understand how can represent the data types. BTW when I try to build all of the needed data the build stop with this faliure:

collect2: fatal error: ld terminated with signal 9 [Killed]

But if I catch correctly what you shown the config is correct

text_sensor:
  - platform: wifi_info
    ip_address:
      id: ip_addr
    ssid:
      id: ssid
    bssid:
      id: bssid
    mac_address:
      id: mac_address
    scan_results:
      id: scan_res
sensor:
  - platform: wifi_signal
    id: wsignal
    update_interval: 5s    

display:
....
           it.printf(2, 10, id(roboto), "IP: %s", id(ip_addr).state.c_str());
           it.printf(2, 20, id(roboto), "SSID: %s", id(ssid).state.c_str());
           it.printf(2, 30, id(roboto), "MAC: %s", id(mac_address).state.c_str());
           it.printf(2, 40, id(roboto), "Signal: %.1f", id(wsignal).state);

And the bug somewhere in the IP/SSID/MAC values but I not able to recognize

Ok i found it and I’m really proud of myself :rofl:

id(ip_addr).state.c_str());

This is the correct syntax

(id(ip_addr).state).c_str());

@Miki_Spetik thanks for the help and for making it clear

2 Likes