I’m new to HA so please forgive me if this is a bonehead question. I created a configuration to read the status of my pool equipment from my Hayward Aqua Connect bridge. I have something that works great, but to parse the web page I have a page-long Jinja template that has to be repeated once for each component I want to monitor (pool pump, heater, lights, etc).
Instead of copying the block of code several times, I created a macro in the custom_templates directory. I’m just not sure how/where to import that so I can use it several times. It works if I import it each time I use it, but that seems wrong. Can I import it such a way that’s it’s available globally?
Here’s what I’m currently doing:
switch:
- platform: template
switches:
pool_spa:
friendly_name: "Spa"
value_template: >-
{% from 'aqua_connect.jinja' import aqua_connect_status %}
{{ aqua_connect_status(2) }}
turn_on:
action: "rest_command.pool_panel"
data:
KeyId: "07"
turn_off:
action: "rest_command.pool_panel"
data:
KeyId: "07"
pool_filter:
friendly_name: "Filter"
value_template: >-
{% from 'aqua_connect.jinja' import aqua_connect_status %}
{{ aqua_connect_status(4) }}
turn_on:
action: "rest_command.pool_panel"
data:
KeyId: "08"
turn_off:
action: "rest_command.pool_panel"
data:
KeyId: "08"
Is there a better way?
Thanks!