Input_text.set_value not working

Hi all
I have tried many ways to get this working, but with no luck. I’m trying to set the input_text. Any ideas?

- trigger:
    platform: numeric_state
    entity_id: sensor.ss_battery_soc
  action:
    service: input_text.set_value
    data:
      value: >-
        {% set ns = namespace(c = '') -%}
        {% if states.sensor.ss_battery_soc.state | int < 40 %}
          {% set ns.c = 'p20' -%}
        {% elif states.sensor.ss_battery_soc.state | int < 45 %}
          {% set ns.c = 'p40' -%}
        {% elif states.sensor.ss_battery_soc.state | int < 65 %}
          {% set ns.c = 'p60' -%}
        {% elif states.sensor.ss_battery_soc.state | int < 95 %}
          {% set ns.c = 'p80' -%}
        {% elif states.sensor.ss_battery_soc.state | int <= 100 %}
          {% set ns.c = 'p100' -%}
        {% endif %}
        {{ ns.c }}
      target:
        entity_id: input_text.ss_battery_charge_level
- trigger:
    platform: numeric_state
    entity_id: sensor.ss_battery_soc
  action:
    service: input_text.set_value
    data:
      value: >-
        {% if states.sensor.ss_battery_soc.state | int < 40 %}
        p20
        {% elif states.sensor.ss_battery_soc.state | int < 45 %}
        p40
        {% elif states.sensor.ss_battery_soc.state | int < 65 %}
        p60
        {% elif states.sensor.ss_battery_soc.state | int < 95 %}
        p80
        {% elif states.sensor.ss_battery_soc.state | int <= 100 %}
        p100
        {% endif %}
    target:
      entity_id: input_text.ss_battery_charge_level

From the docs for the numeric_state trigger.

Fires when the numeric value of an entity’s state crosses a given threshold.

So when should your trigger fire?
Try the state trigger.

Thank you
That seemed to do the trick