Help with lamda prints of sensor stats in Esphome

Trying to pull some sensor data from HA and display it on ESPHome. I assume they are all floats.

sensor:
  - platform: homeassistant
    id: current_temperature
    entity_id: sensor.weather_temperature
    internal: true
    unit_of_measurement: "°F"
  - platform: homeassistant
    id: precip_forcast
    entity_id: sensor.openweathermap_forecast_precipitation_probability
    internal: true
    unit_of_measurement: "%"
  - platform: homeassistant
    id: high_temperature
    entity_id: sensor.openweathermap_forecast_temperature
    internal: true
    unit_of_measurement: "°F"
display:
  - platform: tdisplays3
    id: disp
    update_interval: 1s
    rotation: 270
    lambda: |-
      it.printf(10, 20, id(roboto), Color(255, 0, 0), "Outside Temp:%.1f °F", id(current_temperature));
      it.printf(10, 50, id(roboto), Color(255, 0, 0), "High Temp:%.1f °F", id(current_temperature));
      it.printf(10, 80, id(roboto), Color(255, 0, 0), "Precip Chance:%.1f %", id(precip_forcast));   

Instead of the expected values, it’s cycling between “0.2” and “0.0” and rarely a crazy long number.

Any idea what I’m doing wrong?

Thanks!

As per the docs - values of sensors require .state, e.g. id(my_sensor).state);

So for example yours would be:

    lambda: |-
      it.printf(10, 20, id(roboto), Color(255, 0, 0), "Outside Temp:%.1f °F", id(current_temperature).state);
      it.printf(10, 50, id(roboto), Color(255, 0, 0), "High Temp:%.1f °F", id(current_temperature).state);
      it.printf(10, 80, id(roboto), Color(255, 0, 0), "Precip Chance:%.1f %", id(precip_forcast).state);   

Without .state you are referring to the whole sensor object, not its value. Thus the weird result.

Thanks, that was it.