Displaying HA sensor on display

Hi I am trying to display a HA text senor on a display. I feel that i am close.

to start with, i implemented the display with text, that works then imported the HA sensor, that works. now i am trying to display the HA sensor on the screen, and i have wasted hours trying!

My code so far:

esphome:
  name: display-1

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    
ota:
  password: "de7c0b13c11a729f9eed8e7a1acaa951"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Display-1 Fallback Hotspot"
    password: "Pr9PxjSWZbhg"

captive_portal:

spi:
  clk_pin: D0
  mosi_pin: D1

display:
  - platform: max7219digit
    cs_pin: D8
    num_chips: 4
    lambda: |-
       it.print(0,0, id(digit_font), id(message).state);
#      it.strftime(0, 0, id(digit_font), "%H:%M", id(hass_time).now());
font:
  - file: "gfonts://Roboto"
    id: digit_font
    size: 6

time:
  - platform: homeassistant
    id: hass_time

text_sensor:
  - platform: homeassistant
    id: message
    name: "Display Message"
    entity_id: sensor.sensor_alarm_name

and when compiling it come up with this error:

Compiling /data/display-1/.pioenvs/display-1/src/main.cpp.o
/config/esphome/display-1.yaml: In lambda function:
/config/esphome/display-1.yaml:38:47: error: no matching function for call to 'esphome::max7219digit::MAX7219Component::print(int, int, esphome::display::Font*&, std::string&)'
   38 |        it.print(0,0, id(digit_font), id(message).state);
      |                                               ^

any help on how i get past this would be great.

Thanks

Try

id (message).state.c_str()
1 Like

Amazing, thank you.