Set input_text helper to entity attribute value

I must be missing something completely. But if I trigger this action from an automation, even by hand, no value is saved for input_text.previous_stream. Been searching and trying for an hour.

action: input_text.set_value
metadata: {}
data:
  value: "{{ state_attr('media_player.marantz_sr5015' , 'source') }}"
target:
  entity_id: input_text.previous_stream

If I try "{{ state_attr('media_player.marantz_sr5015' , 'source') }}" in developer tools it correctly shows the value I expected, but “input_text.previous_stream” never receives any value at all. Anyone have an idea?

What does the trace show?

1 Like
params:
  domain: input_text
  service: set_value
  service_data:
    value: BBC 1
    entity_id:
      - input_text.previous_stream
  target:
    entity_id:
      - input_text.previous_stream
running_script: false

The assumption is that you are running this as part of an automation or script.
Jeff is asking for the trace from when this happens.
Select the automation orscript, then look for this in the top, then look thru to find a trace where it fails.

I got that part from the “traces”-button. I see no error whatsoever. I think this is the part that shows the values when executed. I could paste everything that’s under there, but that would take a lot of space? If you can let me know what you’re looking for I can put that info here. If you guys need everything then I’ll do that. By the way, I trigger the action manually as this automation is only automatically triggered once per hour.

Changes variables, Trace timeline, automation config
might be helpful.

What is the length of the value for input_text.set_value?

("{{ state_attr('media_player.marantz_sr5015' , 'source') }}")

Input_text is limited to 255 characters.

I use var.set instead using the Variables Integration

You need to use the attribute, which doesn’t have a character length restriction

This is the action that doesn’t technically fail but doesn’t work as previous_stream doesn’t get the value of media_player.marantz_sr5015.source. It stays empty. Another action works showing that the automation runs.

action: input_text.set_value
metadata: {}
data:
  value: '{{ state_attr(''media_player.marantz_sr5015'' , ''source'') }}'
target:
  entity_id: input_text.previous_stream

Changed variables:

context:
  id: 01K6TC38FTRVA1MZN3GSGC4SQD
  parent_id: 01K6TC38FTN43DGPP4SWH6JQDX
  user_id: null

Trace timeline:

Triggered manually at 5 October 2025 at 16:23:32
Text input 'Set' on Previous stream
Completed at 5 October 2025 at 16:23:32 (executed in 0.00 seconds)

The values are easily under 30 characters. I’ll check out your link, thanks.

Could you post the full automation and a complete trace as JSON (it’s available as an option under the menu)?

1 Like

Automation:

id: '1759603607606'
alias: Change stream
description: ''
triggers:
  - alias: When minute is 55
    trigger: template
    value_template: '{{ now().minute==55 }}'
conditions:
  - condition: and
    conditions:
      - condition: state
        entity_id: media_player.marantz_sr5015
        state: 'on'
      - condition: or
        conditions:
          - condition: state
            entity_id: media_player.marantz_sr5015
            attribute: source
            state: BBC 2
          - condition: state
            entity_id: media_player.marantz_sr5015
            attribute: source
            state: BBC 3
        enabled: false
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: '{{ state_attr(''media_player.marantz_sr5015'' , ''source'') }}'
    target:
      entity_id: input_text.previous_stream
  - action: media_player.play_media
    metadata: {}
    data:
      media:
        media_content_id: >-
          heos://media/1028/station?name=bbc_1&image_url=&playable=True&browsable=False&media_id=s280138
        media_content_type: ''
        metadata:
          title: BBC 1
          thumbnail: ''
          media_class: track
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: ''
              media_content_id: >-
                heos://media/1028/heos_service?name=Favorites&image_url=https%3A%2F%2Fproduction.ws.skyegloup.com%3A443%2Fmedia%2Fimages%2Fservice%2Flogos%2Fmusicsource_logo_favorites.png&available=True
          browse_entity_id: media_player.marantz_sr5015
    target:
      device_id: 5ced62bde093c118de0c91e0b36628e5
    alias: Change stream to BBC 1
    enabled: false
mode: single

Trace:

{
  "trace": {
    "last_step": "action/1",
    "run_id": "e24d48775e474a865b9f14c6d0c00c46",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-10-05T14:23:32.858871+00:00",
      "finish": "2025-10-05T14:23:32.860499+00:00"
    },
    "domain": "automation",
    "item_id": "1759603607606",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2025-10-05T14:23:32.858986+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.change_stream",
              "state": "on",
              "attributes": {
                "id": "1759603607606",
                "last_triggered": "2025-10-05T09:55:53.631361+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Different stream"
              },
              "last_changed": "2025-10-05T09:53:56.427071+00:00",
              "last_reported": "2025-10-05T09:55:53.632644+00:00",
              "last_updated": "2025-10-05T09:55:53.632644+00:00",
              "context": {
                "id": "01K6SWS5MZFKF2HSZZJQM5NDY1",
                "parent_id": "01K6SWS5MY1VAPTZANP3ZHVV28",
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-10-05T14:23:32.859469+00:00",
          "changed_variables": {
            "context": {
              "id": "01K6TC38FTRVA1MZN3GSGC4SQD",
              "parent_id": "01K6TC38FTN43DGPP4SWH6JQDX",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "input_text",
              "service": "set_value",
              "service_data": {
                "value": "BBC 1",
                "entity_id": [
                  "input_text.previous_stream"
                ]
              },
              "target": {
                "entity_id": [
                  "input_text.previous_stream"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2025-10-05T14:23:32.860251+00:00",
          "result": {
            "enabled": false
          }
        }
      ]
    },
    "config": {
      "id": "1759603607606",
      "alias": "Change stream",
      "description": "",
      "triggers": [
        {
          "alias": "When minute is 55",
          "trigger": "template",
          "value_template": "{{ now().minute==55 }}"
        }
      ],
      "conditions": [
        {
          "condition": "and",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "media_player.marantz_sr5015",
              "state": "on"
            },
            {
              "condition": "or",
              "conditions": [
                {
                  "condition": "state",
                  "entity_id": "media_player.marantz_sr5015",
                  "attribute": "source",
                  "state": "NPO Radio 2"
                },
                {
                  "condition": "state",
                  "entity_id": "media_player.marantz_sr5015",
                  "attribute": "source",
                  "state": "NPO 3FM (Hilversum)"
                },
                {
                  "condition": "state",
                  "entity_id": "media_player.marantz_sr5015",
                  "attribute": "source",
                  "state": "SLAM!"
                }
              ],
              "enabled": false
            }
          ]
        }
      ],
      "actions": [
        {
          "action": "input_text.set_value",
          "metadata": {},
          "data": {
            "value": "{{ state_attr('media_player.marantz_sr5015' , 'source') }}"
          },
          "target": {
            "entity_id": "input_text.previous_stream"
          }
        },
        {
          "action": "media_player.play_media",
          "metadata": {},
          "data": {
            "media": {
              "media_content_id": "heos://media/1028/station?name=bbc_1&image_url=&playable=True&browsable=False&media_id=s280138",
              "media_content_type": "",
              "metadata": {
                "title": "BBC 1",
                "thumbnail": "",
                "media_class": "track",
                "children_media_class": null,
                "navigateIds": [
                  {},
                  {
                    "media_content_type": "",
                    "media_content_id": "heos://media/1028/heos_service?name=Favorites&image_url=https%3A%2F%2Fproduction.ws.skyegloup.com%3A443%2Fmedia%2Fimages%2Fservice%2Flogos%2Fmusicsource_logo_favorites.png&available=True"
                  }
                ],
                "browse_entity_id": "media_player.marantz_sr5015"
              }
            }
          },
          "target": {
            "device_id": "5ced62bde093c118de0c91e0b36628e5"
          },
          "alias": "Change stream to BBC 1",
          "enabled": false
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01K6TC38FTRVA1MZN3GSGC4SQD",
      "parent_id": "01K6TC38FTN43DGPP4SWH6JQDX",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Change stream",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.change_stream",
      "context_id": "01K6TC38FTRVA1MZN3GSGC4SQD",
      "domain": "automation",
      "when": 1759674212.8590732
    }
  ]
}

Those don’t match. They have different conditions. Although both conditions are set to enabled: false, that trace is not from that automation.

Need to see the matching trace to an automation.

Not going on a snipe hunt!

That’s weird. Automation Id is the same. I’ll take a look when I get home

Ok, not sure what the problem is to be honest but now I ran the actions and then immediately copied the trace and the automation code.

Code:

id: '1759603607606'
alias: Change stream
description: ''
triggers:
  - alias: When minute is 55
    trigger: template
    value_template: '{{ now().minute==55 }}'
conditions:
  - condition: and
    conditions:
      - condition: state
        entity_id: media_player.marantz_sr5015
        state: 'on'
      - condition: or
        conditions:
          - condition: state
            entity_id: media_player.marantz_sr5015
            attribute: source
            state: BBC 2
          - condition: state
            entity_id: media_player.marantz_sr5015
            attribute: source
            state: BBC 3
          - condition: state
        enabled: false
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: '{{ state_attr(''media_player.marantz_sr5015'' , ''source'') }}'
    target:
      entity_id: input_text.previous_stream
  - action: media_player.play_media
    metadata: {}
    data:
      media:
        media_content_id: >-
          heos://media/1028/station?name=Bbc_1&image_url=&playable=True&browsable=False&media_id=s280138
        media_content_type: ''
        metadata:
          title: BBC 1
          thumbnail: ''
          media_class: track
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: ''
              media_content_id: >-
                heos://media/1028/heos_service?name=Favorites&image_url=https%3A%2F%2Fproduction.ws.skyegloup.com%3A443%2Fmedia%2Fimages%2Fservice%2Flogos%2Fmusicsource_logo_favorites.png&available=True
          browse_entity_id: media_player.marantz_sr5015
    target:
      device_id: 5ced62bde093c118de0c91e0b36628e5
    alias: Change stream to BBC 1
    enabled: false
mode: single

Trace:

{
  "trace": {
    "last_step": "action/1",
    "run_id": "d280b1f6327dfb20ff45df85691ece66",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-10-06T17:27:51.576757+00:00",
      "finish": "2025-10-06T17:27:51.578784+00:00"
    },
    "domain": "automation",
    "item_id": "1759603607606",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2025-10-06T17:27:51.576882+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.Change stream",
              "state": "on",
              "attributes": {
                "id": "1759603607606",
                "last_triggered": "2025-10-05T14:23:32.859077+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Change stream"
              },
              "last_changed": "2025-10-06T17:27:21.153112+00:00",
              "last_reported": "2025-10-06T17:27:21.153112+00:00",
              "last_updated": "2025-10-06T17:27:21.153112+00:00",
              "context": {
                "id": "01K6X90H9ZGXC7Y3Y9GM2JMKGP",
                "parent_id": null,
                "user_id": "3e19b8cfb1814226a392c20333e61a2c"
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-10-06T17:27:51.577385+00:00",
          "changed_variables": {
            "context": {
              "id": "01K6X91F0R1XRYJB9HPT4DJ5DF",
              "parent_id": "01K6X91F0RE6BHH9AJQDKCZGG7",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "input_text",
              "service": "set_value",
              "service_data": {
                "value": "BBC 2",
                "entity_id": [
                  "input_text.previous_stream"
                ]
              },
              "target": {
                "entity_id": [
                  "input_text.previous_stream"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2025-10-06T17:27:51.578504+00:00",
          "result": {
            "enabled": false
          }
        }
      ]
    },
    "config": {
      "id": "1759603607606",
      "alias": "Change stream",
      "description": "",
      "triggers": [
        {
          "alias": "When minute is 55",
          "trigger": "template",
          "value_template": "{{ now().minute==55 }}"
        }
      ],
      "conditions": [
        {
          "condition": "and",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "media_player.marantz_sr5015",
              "state": "on"
            },
            {
              "condition": "or",
              "conditions": [
                {
                  "condition": "state",
                  "entity_id": "media_player.marantz_sr5015",
                  "attribute": "source",
                  "state": "BBC 2"
                },
                {
                  "condition": "state",
                  "entity_id": "media_player.marantz_sr5015",
                  "attribute": "source",
                  "state": "BBC 3"
                }
              ],
              "enabled": false
            }
          ]
        }
      ],
      "actions": [
        {
          "action": "input_text.set_value",
          "metadata": {},
          "data": {
            "value": "{{ state_attr('media_player.marantz_sr5015' , 'source') }}"
          },
          "target": {
            "entity_id": "input_text.previous_stream"
          }
        },
        {
          "action": "media_player.play_media",
          "metadata": {},
          "data": {
            "media": {
              "media_content_id": "heos://media/1028/station?name=Bbc_1&image_url=&playable=True&browsable=False&media_id=s280138",
              "media_content_type": "",
              "metadata": {
                "title": "BBC 1",
                "thumbnail": "",
                "media_class": "track",
                "children_media_class": null,
                "navigateIds": [
                  {},
                  {
                    "media_content_type": "",
                    "media_content_id": "heos://media/1028/heos_service?name=Favorites&image_url=https%3A%2F%2Fproduction.ws.skyegloup.com%3A443%2Fmedia%2Fimages%2Fservice%2Flogos%2Fmusicsource_logo_favorites.png&available=True"
                  }
                ],
                "browse_entity_id": "media_player.marantz_sr5015"
              }
            }
          },
          "target": {
            "device_id": "5ced62bde093c118de0c91e0b36628e5"
          },
          "alias": "Change stream to BBC 1",
          "enabled": false
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01K6X91F0R1XRYJB9HPT4DJ5DF",
      "parent_id": "01K6X91F0RE6BHH9AJQDKCZGG7",
      "user_id": null
    }
  },
  "logbookEntries": []
}