What to replace input_text with to save more than 255 characters

What can I replace input_text with to save more than 255 characters.
I read the documentation and all the topics I found on the forum. I understand that input_text cannot contain more than 255 characters.
There are input_texts that write different information depending on the if branching. Branching can sometimes reach 2-3 nestings. Something like this:

if	condition1
then
  if condition2
  then
	  if
		condition3
	then
		input_text_one: value 1	
	else
		input_text_one: value 2	
  else
    if condition4
    then
	  if
		condition5
	  then
		input_text_one: value 4
	  else
		input_text_one: value 5	
else
 etc...

In some cases, errors are written that the server returns. Errors are longer than 255 characters, and unknown is written to input_text.
This information is not used on the frontend, the information is collected in a message and sent. It is also used in other automations.
Something like this:

message: >
  Response to request:
  Error_one: {{ states('input_text.one_message_telegram_system') }}

The question is, what can I replace input_text with so that the information fits more than 255 characters and is available everywhere?
I tried using a variable, it can store more information, but it does not work in more than one block.

Thanks

You’d have to use a template entity and move all your logic into an attribute on the template entity. Or make a responding script that calculates your response on the fly.

I understand you, Petro.
I thought about it, but I hoped there was another way.
Thanks

P.S. It’s strange why they don’t make a global variable.

Can you tell me how to write down or change the value of an attribute in automation?

You can’t, template entity. Post your automation and I’ll show you how to turn it into a template entity’s attribute

Currently used for input_text
Everything works fine, except when an error occurs when more than 255 characters

alias: Sending values
triggers:
  - trigger: time
    at: "21:00:00"
conditions:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{ (now() + timedelta(days=0)).day == 20 }}"
      - condition: template
        value_template: "{{ has_value('sensor.me_allow_send_data') }}"
    enabled: true
actions:
    # There are 4 such modules so far, they are identical.
    # I didn't insert everything
  - if:
      - condition: and
        conditions:
          - condition: template
            value_template: >-
              {% set difference =
              (state_attr('sensor.sau_water','vals')[0] | float |
              round(0))  - (states('sensor.me_water') | float | round(0))
              %}

              {% if difference | float <  15
              %}true{%else%}false{%endif%}
    then:
      - action: rest_command.one_water_request
        metadata: {}
        data: {}
        response_variable: status_response_one_water
        enabled: true
      - if:
          - condition: template
            value_template: "{{ status_response_one_water['status']  ==  200 }}"
        then:
          - action: input_text.set_value
            metadata: {}
            data:
              value: >-
                "Send \[ID={{state_attr('sensor.me_water','id') }}]
                {{state_attr('sensor.sau_water','vals')[0] | float |
                round(0) }}
                {{state_attr('sensor.sau_water','unit_of_measurement') }}
                {{now().strftime("%m.%Y") }}" 
            target:
              entity_id: input_text.one_water_message_telegram_info
          - action: input_text.set_value
            metadata: {}
            data:
              value: Sent successfully
            target:
              entity_id: input_text.one_water_message_telegram_system
        else:
          - action: input_text.set_value
            metadata: {}
            data:
              value: Sending error. Information in system chat
            target:
              entity_id: input_text.one_water_message_telegram_info
          - action: input_text.set_value
            metadata: {}
            data:
              value: "{{ status_response_one_water['content']['message'] }}"
            target:
              entity_id: input_text.one_water_message_telegram_system
    else:
      - action: input_text.set_value
        metadata: {}
        data:
          value: >-
            "Warning! Very large values:" "{{
            (state_attr('sensor.sau_water','vals')[0] | float | round(0))
            - (states('sensor.me_water') | float | round(0)) }}" 
            "{{state_attr('sensor.sau_water','unit_of_measurement') }}"
            "Sending error"
        target:
          entity_id: input_text.one_water_message_telegram_info
          
    # Next, the information is sent.
   - action: notify.telegram_cannel_info
    metadata: {}
    data:
      message: >
        *Object {{ state_attr('sensor.sau_api_object', 'house')}},{{state_attr('sensor.sau_api_object', 'number') }}*  
        Send one water {{states('input_text.one_water_message_telegram_info') }}   
        Send two water {{states('input_text.tho_water_message_telegram_info') }}
        Send three water {{states('input_text.three_water_message_telegram_info') }}   
        Send four water {{states('input_text.four_water_message_telegram_info') }}
  - action: notify.telegram_cannel_system
    metadata: {}
    data:
      message: >
        Server response: 
        One water = {{ status_response_one_water['status'] }}  
        Error: {{ states('input_text.one_water_message_telegram_system') }}  
        Two water = {{status_response_two_water['status'] }}  
        Error: {{ states('input_text.two_water_message_telegram_system') }}
        Three water = {{status_response_three_water['status'] }}  
        Error: {{ states('input_text.three_water_message_telegram_system') }}
        Four water = {{status_response_four_water['status'] }}  
        Error: {{ states('input_text.four_water_message_telegram_system') }}
mode: single

So I want to replace input_text with something that contains more characters.

There are two integrations that create sensors that can be used as global variables. Take a look at
https://github.com/snarky-snark/home-assistant-variables/blob/6fd48b28b785bc32a8a53c36a28d55d73fc5d4a8/README.md
and
https://github.com/enkama/hass-variables

I use both, the second allows yoy to create a history of the value if that is something you need.

Art

1 Like