Newbie - Help with Text Senors to Nextion Display

Hi all,

Trying to get my display to update based on a input_text field in HA. I have a text_input helper in HA.

This is the esphome portion

text_sensor:

 - platform: homeassistant
   entity_id: input_text.text1
   attribute: text1
   id: input_text1
   on_value:
       then:
         - lambda: id(disp1).set_component_text_printf("t1", "%s", id(input_text1).state.c_str());

But I can’t get the display to update t1 on the nextion screen.

Remove the attribute: text1 line, you want to show the state off input_text.text1 and that’s the default attribute.

Hi All,

I have same problem:

  - platform: homeassistant
    id: nspanel_text
    entity_id: input_text.nspanel
    on_value:
      # Push it to the display
      then:
        - lambda: 'id(disp1).set_component_text_printf("t1", "%s", id(nspanel_text).state.c_str());'

Error message:
/config/esphome/nspanel-teszt.yaml: In lambda function:
/config/esphome/nspanel-teszt.yaml:104:72: error: request for member ‘c_str’ in ‘nspanel_text->esphome::homeassistant::HomeassistantSensor::.esphome::sensor::Sensor::state’, which is of non-class type ‘float’

correct error message is:

/config/esphome/nspanel-teszt.yaml: In lambda function:
/config/esphome/nspanel-teszt.yaml:104:72: error: request for member 'c_str' in 'nspanel_text->esphome::homeassistant::HomeassistantSensor::<anonymous>.esphome::sensor::Sensor::state', which is of non-class type 'float'```

I miss the most important line from your yaml-config :slight_smile:: What kind of sensor is ns_panel_text? It looks like you defined it as a sensor: (their state is always a float) instead of a text_sensor:

1 Like

Perfect that fixed it !!!

It woks ! Thx !