Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106482

Data_template with optional parameters

$
0
0

I need to do automation with conditions, but some parameters are sometimes not needed. In second condition parameter position not needed. I’m try do it via JSON (below), but it not works.

  action:
    service_template: >
      {% if action == 'open' %}
        {% if x %}
          cover.set_cover_position
        {% else %}
          cover.open_cover
        {% endif %}
      {% elif action == 'close' %}
        {% if x %}
          cover.set_cover_position
        {% else %}
          cover.close_cover
        {% endif %}
      {% endif %}
    data_template: >
        {% if place == "balcony" and percent %}
          {'entity_id':'group.balcony_covers','position': percent }
        {% elif place == "room" and percent  %}
          {'entity_id':'group.room_covers','position': percent  }
        {% elif place == "balcony" and not percent  %}
          {'entity_id':'group.balcony_covers'}
        {% elif place == "room" and not percent  %}
          {'entity_id':'group.room_covers'}
        {% endif %}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106482

Trending Articles