MQTT topic/payload to helper

hello ,

Creating a Text Helper to Display MQTT Topic Payload

I want to create a helper (TextHelper) that displays the payload of an MQTT topic. However, I don’t have access to the configuration.yaml file. Instead, I’ve created an automation that is triggered by the topic.

Capturing the Payload

My main problem is capturing the actual payload and sending it as an action to the TextHelper. Is my approach possible?

kind regards

:face_with_raised_eyebrow: Why not?

Yes, using the input_text.set_value service (docs) and the MQTT trigger variables (docs):

action:
  - service: input_text.set_value
    target:
      entity_id: input_text.YOUR_HELPER_ID
    data:
      value: "{{ trigger.payload }}"

If there’s a risk that the payload could exceed the entity state limit of 255 characters, use:

      value: "{{ trigger.payload[:255] }}"

to truncate it.

its a 3th party device with a custom Homeassistant , and only the manufacturer has “root” acces.

Ontopic : your solution works fine , thanks for helping me in the right direction about the trigger.

1 Like