Testing jinja macro

This commit is contained in:
2025-02-22 17:45:14 +01:00
parent b79a7abfcd
commit bd08d22d03
2 changed files with 76 additions and 7 deletions

View File

@@ -1,9 +1,27 @@
{% macro getpower_id(evcharge_id) %}
{# This macro returns _power entity for a controlled plug device #}
{% macro getpower_id(evcharge_id) %}
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
{% for attrib in attrib_list %}
{% if ( attrib | regex_search('power$')) %}
{{ attrib }}
{% endif %}
{% endfor %}
{% endmacro %}
{% for attrib in attrib_list -%}
{% if ( attrib | regex_search('power$')) -%}
{{ attrib }}
{%- endif %}
{%- endfor %}
{% endmacro %}
{########################################################################}
{# This macro returns _energy entity for a controlled plug device #}
{% macro getenergy_id(evcharge_id) %}
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
{% for attrib in attrib_list -%}
{% if ( attrib | regex_search('energy$')) -%}
{{ attrib }}
{%- endif %}
{%- endfor %}
{% endmacro %}