I managed to figure out a working solution for converting the OrderedDict back into YAML Lovelace configuration. I kept bumping into some sort of quirk where it wouldnât allow me to apply the tojson
filter directly to the OrderedDict object. ButâŚit allowed me to apply the list
filter to retrieve the keys in the OrderedDictâŚand for some reason it also allowed me to to apply tojson
to their corresponding values.
So this approach worksâŚ
{% for key in options|list %}
{{ key }}: {{ options[key]|tojson }}
{% endfor %}
Technically, this doesnât produce 100% âpureâ YAML formatâŚthe generated Lovelace config has YAML keys, and the corresponding values are Javascript objects. But that is totally valid from a YAML perspective, and it is generating the hold_action config that I was looking for.
@petro, thank you for your assistance and your sample code - it pushed me in the right direction!