So I have one of those 16x2 LCD Displays. It’s connected to a nodemcu and it’s working and I can print simple text to it no problems.
What I want to be able to do is print a state from a sensor from Home Assistant.
My yaml looks like this:
esphome:
name: node_lcd
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "MY-SSID"
password: "MY-PASS"
# Optional manual IP
manual_ip:
static_ip: 10.90.11.57
gateway: 10.90.11.1
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
i2c:
sda: D2
scl: D1
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
lambda: |-
it.print("Weather: %s", id(weather).state.c_str());
it.print(1, 0, "Sun: %s", id(sun).state.c_str());
web_server:
port: 80
text_sensor:
- platform: homeassistant
id: weather
name: weather
entity_id: weather.home
internal: true
- platform: homeassistant
id: sun
name: sun
entity_id: sun.sun
internal: true
My errors on compilation are:
src/main.cpp: In lambda function:
src/main.cpp:167:53: error: no matching function for call to 'esphome::lcd_base::LCDDisplay::print(const char [12], const char*)'
it.print("Weather: %s", weather->state.c_str());
^
src/main.cpp:167:53: note: candidates are:
In file included from src/esphome.h:16:0,
from src/main.cpp:3:
src/esphome/components/lcd_base/lcd_display.h:31:8: note: void esphome::lcd_base::LCDDisplay::print(uint8_t, uint8_t, const char*)
void print(uint8_t column, uint8_t row, const char *str);
^
src/esphome/components/lcd_base/lcd_display.h:31:8: note: candidate expects 3 arguments, 2 provided
src/esphome/components/lcd_base/lcd_display.h:33:8: note: void esphome::lcd_base::LCDDisplay::print(uint8_t, uint8_t, const string&)
void print(uint8_t column, uint8_t row, const std::string &str);
^
src/esphome/components/lcd_base/lcd_display.h:33:8: note: candidate expects 3 arguments, 2 provided
src/esphome/components/lcd_base/lcd_display.h:35:8: note: void esphome::lcd_base::LCDDisplay::print(const char*)
void print(const char *str);
^
src/esphome/components/lcd_base/lcd_display.h:35:8: note: candidate expects 1 argument, 2 provided
src/esphome/components/lcd_base/lcd_display.h:37:8: note: void esphome::lcd_base::LCDDisplay::print(const string&)
void print(const std::string &str);
^
src/esphome/components/lcd_base/lcd_display.h:37:8: note: candidate expects 1 argument, 2 provided
src/main.cpp:168:51: error: no matching function for call to 'esphome::lcd_base::LCDDisplay::print(int, int, const char [8], const char*)'
it.print(1, 0, "Sun: %s", sun->state.c_str());
^
src/main.cpp:168:51: note: candidates are:
In file included from src/esphome.h:16:0,
from src/main.cpp:3:
src/esphome/components/lcd_base/lcd_display.h:31:8: note: void esphome::lcd_base::LCDDisplay::print(uint8_t, uint8_t, const char*)
void print(uint8_t column, uint8_t row, const char *str);
^
src/esphome/components/lcd_base/lcd_display.h:31:8: note: candidate expects 3 arguments, 4 provided
src/esphome/components/lcd_base/lcd_display.h:33:8: note: void esphome::lcd_base::LCDDisplay::print(uint8_t, uint8_t, const string&)
void print(uint8_t column, uint8_t row, const std::string &str);
^
src/esphome/components/lcd_base/lcd_display.h:33:8: note: candidate expects 3 arguments, 4 provided
src/esphome/components/lcd_base/lcd_display.h:35:8: note: void esphome::lcd_base::LCDDisplay::print(const char*)
void print(const char *str);
^
src/esphome/components/lcd_base/lcd_display.h:35:8: note: candidate expects 1 argument, 4 provided
src/esphome/components/lcd_base/lcd_display.h:37:8: note: void esphome::lcd_base::LCDDisplay::print(const string&)
void print(const std::string &str);
^
src/esphome/components/lcd_base/lcd_display.h:37:8: note: candidate expects 1 argument, 4 provided
*** [/data/nick_lcd/.pioenvs/nick_lcd/src/main.cpp.o] Error 1
I am simply wanting to print the weather state and the sun state…
ie Weather: sunny
sun: above_horizon
This code:
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
lambda: |-
it.print("Weather");
it.print(0, 1, "Sun");
Just prints 2 lines without the state but it works…
ok… this seems to work:
it.printf(0, 0, "Sun: %s", id(sun).state.c_str());