ESP Home display shows NAN even though state has a number

sensor:
  - platform: homeassistant
    name: "Outside temperature"
    id: outside_temperature
    entity_id: sensor.outdoor_switchbot 

display:
  - platform: waveshare_epaper
    cs_pin: GPIO15
    dc_pin: GPIO12
    busy_pin: GPIO5
    reset_pin: GPIO4
    model: 2.13in-ttgo-dke
    reset_duration: 2ms
    update_interval: 60s
    full_update_every: 30
    lambda: |-
      it.printf(0,50,id(anton), TextAlign::BASELINE_LEFT, "Outside: %.1f °C", id(outside_temperature).state);

In the logs I see this:
[17:36:02][C][homeassistant.sensor:030]: Homeassistant Sensor ‘Outside temperature’
[17:36:02][C][homeassistant.sensor:030]: State Class: ‘’
[17:36:02][C][homeassistant.sensor:030]: Unit of Measurement: ‘’
[17:36:02][C][homeassistant.sensor:030]: Accuracy Decimals: 1
[17:36:02][C][homeassistant.sensor:031]: Entity ID: ‘sensor.outdoor_switchbot’
[17:36:02][D][homeassistant.sensor:024]: ‘sensor.outdoor_switchbot’: Got state 8.00
[17:36:02][D][sensor:093]: ‘Outside temperature’: Sending state 8.00000 with 1 decimals of accuracy

However, on the display itself it just shows “Outside: nan °C”

I am at a loss on why this doesn’t work.

You may need to specify your HA sensor as not internal. They are internal by default and will not show a sensor value or send a repeat sensor value back to HA when internal is ON but, that may be whats stopping it from being displayed.

sensor:
  - platform: homeassistant
    name: "Outside temperature"
    id: outside_temperature
    entity_id: sensor.outdoor_switchbot 
    internal: false

Im not totally sure what your building but, just a suggestion. If your going to pull a HA temp sensor value then you would be better off to use whatever your preferred weather add on is and then do cool things like display rain/thunderstorm warnings or a tornado warning perhaps erc, etc

I use OpenWeatherMap and there’s no shortage of sensors to choose from!

Not true, all sensors in ESPHome provide floating point values.

Actually - you are right,… I was thinking of text_sensor:

Apologies to OP…

Do you have added esp to HA?

my line is a little different than your:

        if(id(weather_temperature).has_state ()) {
            it.printf(145, 260, id(font_small_bold), color_black, TextAlign::BASELINE_LEFT, "%s", "°C");
            it.printf(140, 260, id(font_weekday), color_black, TextAlign::BASELINE_RIGHT, "%2.0f", id(weather_temperature).state);
        }

It turns out that this is the problem. Although I had added it to home assistant. Home Assistant seems to have a hard time seeing it. I have tried it with a new esp32 and start from scratch and able to make it work.