#Too many newlines in YAML for Action "telegram_bot.send_message"

1 messages · Page 1 of 1 (latest)

chilly matrix
#

Hey there,

I try to get an calendar notification automation up and running.
Functionally, all is good and well, however, formatting is still a mess. If I use the following code to send a telegram message, I usually get a lot of newlines between events, no matter if I use ">-", "|" or ">" as YAML newline treatment. Also, setting the markdown style for teleram does not change the output. Any idea what's wrong

actions:
  - data:
      duration:
        hours: 48
    target:
      entity_id: calendar.abfallkalender
    response_variable: agenda
    action: calendar.get_events
  - if:
      ...
    then:
      - data:
          target: -1001456132488
          title: '📆<b>Batzbot Kalender</b>'
          parse_mode: html
          message: >-
            Morgen ist was los. Hier sind die geplanten Ereignisse:
            {% set tomorrow = (now().timestamp() + 86400) | timestamp_custom('%Y-%m-%d') %}
            {% for event in agenda['calendar.abfallkalender']['events'] %}
              {% set start_date = as_timestamp(event.start) | timestamp_custom('%Y-%m-%d') %}
              {% if start_date == tomorrow %}
                {% if event.start is defined %}
                  {% set start_date_time = as_timestamp(event.start) | timestamp_custom('%Y-%m-%d %H:%M') %}
                  {% if '00:00' in start_date_time %}
                    - {{ event.summary }} (ganztags)
                  {% else %}
                    - {{ event.summary }} um {{ start_date_time.split(' ')[1] }}
                  {% endif %}
                {% else %}
                  - {{ event.summary }} (ganztags)
                {% endif %}
              {% endif %}
            {% endfor %}
        action: telegram_bot.send_message

Output:

📆Batzbot Kalender
"Morgen ist was los. Hier sind die geplanten Ereignisse:  
  
  
    
      
      
        - Gelber Sack (ganztags)
      
    
  

  
  
    
      
      
        - Testevent um 08:15
      
    
  

Best
Robin

rare vine
#

You can replace the Jinja end blocks with -%} to remove a new line at the end. Or -}} if it's a print.

chilly matrix
#

Thank you, this worked. However, I have looked for a solution for long, is this documented or just something you need to know? The common YAML behavior does not seem to work