@skalavala This is not working. So, here is an example that we can all play with in the template editor. I manually set value_json
to state_attr('image_processing.tensorflow_driveway','matches')
{% set value_json = {'person': [{'score': 99.69417452812195, 'box': [0.2749924957752228, 0.3772248923778534, 0.6910392045974731, 0.4704430401325226]}], 'car': [{'score': 99.01034832000732, 'box': [0.34889374375343323, 0.21685060858726501, 0.23301419615745544, 0.3547678291797638]}, {'score': 99.01034832000732, 'box': [0.54889374375343323, 0.21685060858726501, 0.23301419615745544, 0.3547678291797638]}, {'score': 98.71577620506287, 'box': [0.14932020008563995, 0.3567427694797516, 0.22214098274707794, 0.4808700978755951]}]} %}
{% set camera = 'driveway' %}
{%- set tags = value_json.keys()|list -%}
{%- for object in tags -%}
{%- for x in value_json[object]|list if x.box[0] > 0.25 -%}
{%- if loop.first %}{% elif loop.last %}, {% else %},{% endif -%}{{ object }}
{%- endfor -%}
{% endfor -%}
{{- ' detected in ' ~ camera if tags|count |int > 0 }}
returns personcar, car detected in driveway
. It should, instead, return person, car detected in driveway
. Further, if we try the same code with
{% set value_json = {'car': [{'score': 99.01034832000732, 'box': [0.14889374375343323, 0.21685060858726501, 0.23301419615745544, 0.3547678291797638]}, {'score': 98.71577620506287, 'box': [0.14932020008563995, 0.3567427694797516, 0.22214098274707794, 0.4808700978755951]}]} %}
we get detected in driveway
. The second one should be empty.