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

How to only return one match Jinja

$
0
0

@jaswalters wrote:

In other languages I would normally break the loop.

Since Jinja cannot break how do I only return the first match?

{% set inputerr = False %}
{%- for state in states.input_text -%}
{% if (( state.entity_id | regex_match('^input_text.lockcode_([0-9]|[12][0-9]|30)$')) and
(state.state != 'unknown')) %}
{% set slotusercode = state.state.split(':') -%}
{% if slotusercode[1][0:4]|int() == states("input_text.lockcode_code")[0:4]|int() %}
{% set inputerr = True %}
{{inputerr}}
{%- endif %}
{%- endif %}
{%- endfor %}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 102460

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>