Open Aleborg opened 1 year ago
Solved it by using jinja2's import:
{% import '/config/includes/lovelace/my-tablet/settings/settings.json' as settings -%}
Just to bad that I have to use the full path :/
Here's another way that has the benefit of being able to pluck sub objects (keys) which I couldn't get to work using your version...
a generic macro followed by a templated call to the macro.
has allowed me to replace 100's of lines of clunky yaml, with nice clean json...and pull it in all over the place.
If I could figure out how to do it with an import and a key, that would be even better. but I can't get something like:
{% from '/config/yaml/imports/footer-buttons.yaml' import porch as footer_data with context %}
to work.
But the below does work.
{% macro import_json(source) %}
{% include source %}
{% endmacro %}
{% set dpad_device = "firetv" %}
{% set dpad_file = '/config/yaml/imports/dpad_buttons.json' %}
{% set dpad_data = (import_json(dpad_file) | fromjson)[dpad_device] %}
{% set dpad_entity = "media_player.fire_tv_192_168_1_91" %}
Is it possible somehow to include variables from another file somehow?
I tried these two methods, but actually didn't expect it to work (and it didn't):
and in json-settings.yaml:
And this version as well:
and in json-settings.yaml:
Also tried using jinja2 include without success. I'm trying to avoid using global variables (requires a restart of HA)
Does anyone have any ideas on how to solve this?