Sensor with string value

Hello everybody,

Beginner in YAML, I need to set a new sensor from my inverter. the resultat is a string and I don’t know what is wrong in my template.
Thanks in advance for your help.

‘’‘- sensor:
- name: “Mode inverter”
state: >
{% set gd_items = state_attr(‘sensor.inverter_data’, ‘gd_’) %}
{{ (gd_items | selectattr(‘id’, ‘equalto’, ‘gd_ac_input_range’) | map(attribute=‘val’) | list) }}
device_class: “setup_inverter”
‘’’

resultat

  • sensor:
    • name: “Mode inverter”
      state: >

      [‘UPS’]
      device_class: “setup_inverter”

[{‘id’: ‘gd_ac_input_frequency’, ‘par’: ‘AC Input Frequency’, ‘val’: ‘0.0’, ‘unit’: ‘Hz’}, {‘id’: ‘gd_mains_status’, ‘par’: ‘Mains Status’, ‘val’: ‘Mains Abnormality’}, {‘id’: ‘gd_ac_input_voltage’, ‘par’: ‘AC Input Voltage’, ‘val’: ‘0.0’, ‘unit’: ‘V’}, {‘id’: ‘gd_ac_input_range’, ‘par’: ‘AC Input Range’, ‘val’: ‘UPS’}]

Every entity’s state value is treated as a string. In addition, an entity’s state is limited to holding 255 characters.

Your Template Sensor’s template produces a list but it gets stored as a string. However, your list contains 324 characters which exceeds the limit.