LCD Display, show more sensors, what is the right syntax

Hi Guys.

I Started yesterday to play with lcd display for the first time, I set a 20x4 lcd display up with my Nodemcu esp32s board with esphome, and it works great. I have until now added a temperature sensor via home assistant to show the state on the display, my problem is how to add more sensor data to the display…

The problem is the right syntax combination of if, else, then, that I need help to.
The temp sensor is working fine, but I want to add the humidity sensor too, but I get error after uploading the code to the esp32s…

Can someone please guide me the right way ?

My code is posted here under:

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    lambda: |-
      
      it.print(0, 0, "Temp:");
      if (id(sensenode_temp_2).state == id(sensenode_temp_2).state) {
      it.printf(5, 0,"%.1fC", id(sensenode_temp_2).state);
      } else {
      it.print(0, 1, "Humidity:");
      if (id(sensenode_humidity_2).state == id(sensenode_humidity_2).state) {
      it.printf(5, 1,"%.1fC", id(sensenode_humidity_2).state);
      } else {
      it.print(0, 2, "Enheden startes");
      }

Best Regard slindberg

I solve my problem.
It works, I just need now to find the right format unit for humidity to the code
with this code instead:

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    lambda: |-
      // Print office temperature (from homeassistant sensor)
      it.print(0, 0, "Temp:"); it.print(0, 3, "Humidity:");
      if (id(sensenode_temp_2).state == id(sensenode_temp_2).state) 
      it.printf(5, 0,"%.1fC", id(sensenode_temp_2).state);
      if (id(sensenode_humidity_2).state == id(sensenode_humidity_2).state) {
      it.printf(9, 3,"%.1f%", id(sensenode_humidity_2).state);
      } else {
      it.print(0, 2, "Enheden startes");
      }
1 Like