Skip to content

Script/Automation Trace download - truncate when have Jinja comments #146760

Open
@ceinmart

Description

@ceinmart

The problem

I have an script which I include few comments into the jinja template.
When I download the trace file , the json became truncated at "{#".

I copied the yaml block on their section below here in the issue.

This is how the trace file end when I download it :

...
          "repeat": {
            "sequence": [
              {
                "variables": {
                  "vAr_ModoAtual": "{{ states('climate.ar_condicionado_augusto') }}",
                  "vAr_TempAtual": "{{ state_attr('climate.ar_condicionado_augusto','temperature') }}",
                  "vAr_SwingAtual": "{{ state_attr('climate.ar_condicionado_augusto','swing_mode') }}",
                  "vAr_FanAtual": "{{ state_attr('climate.ar_condicionado_augusto','fan_mode') }}",
                  "vSensorA": "{{ states[states('input_select.ar_augusto_sensores_temp')] }}",
                  "vSensor": "{% set vT = states('input_select.ar_augusto_sensores_temp') %} \n{% set vS = states[vT] %} \n{

What version of Home Assistant Core has the issue?

core-2025.6.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Automation , Scripts

Link to integration documentation on our website

No response

Diagnostics information

I think this one didn't have this option.

Example YAML snippet

- repeat:
      sequence:
        - variables:
            vAr_ModoAtual: "{{ states('climate.ar_condicionado_augusto') }}"
            vAr_TempAtual: "{{ state_attr('climate.ar_condicionado_augusto','temperature') }}"
            vAr_SwingAtual: "{{ state_attr('climate.ar_condicionado_augusto','swing_mode') }}"
            vAr_FanAtual: "{{ state_attr('climate.ar_condicionado_augusto','fan_mode') }}"
            vSensorA: "{{ states[states('input_select.ar_augusto_sensores_temp')] }}"
            vSensor: >-
              {% set vT = states('input_select.ar_augusto_sensores_temp') %} 

              {% set vS = states[vT] %} 

              {# se sensor eh xiaomi e ultima coleta tem +4min, usa a
              temperatura do ar augusto #}  

              {% if (vT | regex_match(".*xiaomi.*temp", ignorecase=true)) and 
                (((now() - vS.last_updated).total_seconds() | int) >= 300)  %}
                {% set vT = 'sensor.ar_condicionado_augusto_room_temperature' %}
              {% endif %}  {{ vT }}
            vSensor_lastup: >-
              {{ (now() - (states[vSensor].last_updated)).total_seconds() | int
              }}
            vSensor_fn: "{{ state_attr(vSensor, 'friendly_name') }}"
            vSensor_temp: |-
              {% macro is_valid_number(value) %}
                {{ value | regex_match('^[-+]?[0-9]*\.?[0-9]+$') }}
              {% endmacro %} {% if is_valid_number(states(vSensor)) %} 
                {% if ( vSensor | regex_match(".*xiaomi.*") ) -%}
                  {{ states(vSensor) | float -}}
                {% else %}
                  {# se nao eh sensor xiaomi, eh o sensor do ar-condicionado , que da sempre uns 5 graus a mais #}
                  {# quando esta com o aquecimento ligado #}
                  {% if vAr_ModoAtual == 'heat' %} 
                    {{ (states(vSensor)| float) -5 -}}
                  {% else %}
                    {{ (states(vSensor)| float) -}}
                  {% endif %}
                {% endif %}
              {% else %}
                -1
              {% endif %}

Anything in the logs that might be useful for us?

nothing that I identified.
Since no error occur, just data truncated.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions