Esphome, show local weather sensor date on 20x4 lcd display, standalone without home assistant, how?

Hey :slight_smile:

I have build a simple weather station with a Nodemcu esp32s board running esphome and with a AM2301 temp & humidity sensor.

In the moment the code are setup to send sensor data to home assistant and after send the state data back to nodemcu esp32s for to print it to the lcd display.

I would like to skip the home assistant step and directly let nodemcu esp32s send the temp & humidity sensor data to the display locally.

How could the code look out ?

I post here my code as it is in the moment then its stille are running together with home assistant.

# | Sensorer |
  - platform: dht
    pin: 27
    model: dht22 
    id: temp
      name: "SenseNode Temp"
      name: "SenseNode Humidity"
    update_interval: 25s

  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    lambda: |-
      // Print office temperature (from homeassistant sensor)
      it.print(0, 0, "VEJRSTATION:"); it.print(0, 1, "Temp:"); it.print(0, 2, "Humidity:");
      if (id(sensenode_temp_2).state == id(sensenode_temp_2).state) 
      it.printf(5, 1,"%.1fC", id(sensenode_temp_2).state);
      if (id(sensenode_humidity_2).state == id(sensenode_humidity_2).state) {
      it.printf(9, 2,"%.1f%%\n", id(sensenode_humidity_2).state);
      it.printf(0, 3,"", id(my_time));
      it.strftime(0, 3, "%H:%M:%S %d.%m.%Y", id(my_time).now());
      } else {
      it.print(4, 3, "Loading Wait!");

# Home assistant Sensor    
  - platform: homeassistant
    id: sensenode_temp_2
    entity_id: sensor.sensenode_temp_2
    internal: true 
  - platform: homeassistant
    id: sensenode_humidity_2
    entity_id: sensor.sensenode_humidity_2
    internal: true    

Best regards slindberg

You should be able to reference the local values of the sensors you are pulling back from Home Assistant. Just not sure of the exact code to use in the display lambda.

You almost have everything you need. Here is an example from my code.

  - platform: dht
    pin: 33
    model: DHT11
      id: room_temp
      name: "Room Temperature"
      id: room_humid
      name: "Room Humidity"

then simply access both values in your lambda like so

  lambda: |-
    x = id(room_temp).state;
    y = id(room_humid).state;