How to append additional text to an existing text helper

I am trying to build a script that will test a set of conditions and return a count of results and a text list summarizing them. My source data is a HACS integration called Ham Radio Propagation. There are four entities return a state of Good, Fair, or Poor for the amateur radio bands. I want to count how many of those have a state of “Good” and store that in a number helper. And I want to build out a text string that lists them and store that in a text helper.

The first to actions in the script set the numeric helper to zero and the text helper to an initial string of “The”. The conditional tests are working, and the numeric counter is also working. But I’m stumped on how to append additional text to an existing text help.

I added an input text set value action to my script and then switched to yaml view to see what it generated for code. This is what I got:

action: input_text.set_value
metadata: {}
data:
  value: some test text
target:
  entity_id: input_text.band_good_list

For each entity (band status) that has a state of “good” I want to append a text sting to the text helper. The goal being to have a text helper that I can use in an announcement or notification that tells me which of the propagation bands are in good condition. For example if the 10m band is good I want to take the existing text help value of “The” and append the string “10m Band” to it. If the next conditional test that shows good is the 17m band I want to append that band title to that text helper so it now reads “The 10m Band and 17m Band”.

Basically I need to create some code to do this for each band: Old_Text = Old_Text + New Text.

I read some of the documentation and numerous posts and based on this I’ve tried several things that did’t work.

I’ve tried these and several variations, none of which have worked:

value: "{{ states(input_text.band_good_list) + some new text }}"

value: "{{ states(input_text.band_good_list) ` some new text }}"

value: "{{ states(input_text.band_good_list.state) ` some new text }}"

Clearly, I’m not grasping text string manipulation and could use some pointers.

Any help would be greatly appreciated!
Tom G.

This should work:

value: "{{ states('input_text.band_good_list') + 'some new text' }}"

So should this (preferred)

value: "{{ states('input_text.band_good_list') ~ 'some new text' }}"

Or this:

value: "{{ states('input_text.band_good_list') }} some new text"

Note that there is a limit of 255 characters for the input_text state value.

1 Like