Input_text.set data value format issue

I am trying to set an input_text value to a text string based on the entity id that has set off a trigger. I am struggling with:

  1. How the trigger.entity_id is defined in the value text
  2. When testing the entity_id against texts, how that string should be formatted

I have had several attempts so the yaml below is only the current syntax.

service: input_text.set_value
target:
  entity_id: input_text.harmony_activity_new
data:
  value: >-
    {% set roku_button = trigger.entity_id %} {% if roku_button ==
    "irreceiver_green_up_small_netflix" %}
    Netflix
    {% elif roku_button == "irreceiver_blue_up_small_prime_video" %}
    Prime
    {% elif roku_button == "irreceiver_red_down_small_youtube" %}
    YouTube
    {% elif roku_button == "irreceiver_green_down_small_bbc_iplayer" %}
    BBCiPlayer
    {% elif roku_button == "irreceiver_blue_down_small_all4" %}
    All4
    {% elif roku_button == "irreceiver_diy_1_disney_plus" %}
    Disney
    {% elif roku_button == "irreceiver_diy_2_my5" %}
    My5
    {% elif roku_button == "irreceiver_diy_4_now_tv" %}
    NowTV
    {% elif roku_button == "irreceiver_diy_5_itvx" %}
    ITVX
    {% elif roku_button == "irreceiver_diy_6_apple_tv" %}
    AppleTV
    {% endif %}

This current version returns the following message:

Message malformed: template value should be a string for dictionary value @ data['action'][0]['choose'][4]['sequence'][1]['data']

How should this be formatted?

None of those stings you are comparing are entity ids. Entity ids are of the form: domain.object_id e.g switch.bedroom_fan

Please post your trigger section so we can see what the entity_ids are supposed to be.

platform: state
entity_id:
  - binary_sensor.irreceiver_green_up_small_netflix
  - binary_sensor.irreceiver_blue_up_small_prime_video
  - binary_sensor.irreceiver_red_down_small_youtube
  - binary_sensor.irreceiver_green_down_small_bbc_iplayer
  - binary_sensor.irreceiver_blue_down_small_all4
  - binary_sensor.irreceiver_diy_1_disney_plus
  - binary_sensor.irreceiver_diy_2_my5
  - binary_sensor.irreceiver_diy_4_now_tv
  - binary_sensor.irreceiver_diy_5_itvx
  - binary_sensor.irreceiver_diy_6_apple_tv
id: Roku Activity
from: "off"
to: "on"

The reason I did not add the “binary_sensor” text is because I had elsewhere created a variable from a trigger:

variables:
  sensor_trigger_name: "{{ trigger.entity_id }}"
enabled: true

and, when passed into a script, it did not have the domain on the front:

                          - service: script.irreceiver_roku_buttons
                            data:
                              sensor_trig_id: "{{ sensor_trigger_name }}"
 

Not sure quite what was going on as I fixed it and, in this instance, binary_sensor was attached as the domain. I also did the same thing as previously by setting the variable actually in the trigger:

platform: state
entity_id:
  - binary_sensor.irreceiver_green_up_small_netflix
  - binary_sensor.irreceiver_blue_up_small_prime_video
  - binary_sensor.irreceiver_red_down_small_youtube
  - binary_sensor.irreceiver_green_down_small_bbc_iplayer
  - binary_sensor.irreceiver_blue_down_small_all4
  - binary_sensor.irreceiver_diy_1_disney_plus
  - binary_sensor.irreceiver_diy_2_my5
  - binary_sensor.irreceiver_diy_4_now_tv
  - binary_sensor.irreceiver_diy_5_itvx
  - binary_sensor.irreceiver_diy_6_apple_tv
id: Roku Activity
from: "off"
to: "on"
variables:
  sensor_trigger_name: "{{ trigger.entity_id }}"
enabled: true
service: input_text.set_value
target:
  entity_id: input_text.harmony_activity_new
data:
  value: >-
    {% if sensor_trigger_name == 'binary_sensor.irreceiver_green_up_small_netflix' %}
    Netflix {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_blue_up_small_prime_video' %} Prime {% elif
    sensor_trigger_name == 'binary_sensor.irreceiver_red_down_small_youtube' %} YouTube {%
    elif sensor_trigger_name == 'binary_sensor.irreceiver_green_down_small_bbc_iplayer' %}
    BBCiPlayer {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_blue_down_small_all4' %} All4 {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_diy_1_disney_plus' %} Disney {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_diy_2_my5' %} My5 {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_diy_4_now_tv' %} NowTV {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_diy_5_itvx' %} ITVX {% elif sensor_trigger_name ==
    'binary_sensor.irreceiver_diy_6_apple_tv' %} AppleTV 
    {% endif %}
enabled: true

If you don’t want the domain part of the entity id (e.g. ‘binary_sensor’) then use:

sensor_trigger_name: "{{ trigger.object_id }}"