Using the flatten filter in scripts and rest sensors causes them to break after a restart #824
Unanswered
philipdouglas
asked this question in
Q&A
Replies: 1 comment
-
After writing the above, I discovered the value_template: >-
{% if "flatten" is filter %}
{{ value_json.data.category_groups | map(attribute="categories") | flatten(levels=1) | selectattr("balance", "lt", 0) | list | length }}'
{% else %}
unavailable
{% endif %} Even well after a restart, this sensor is stuck as "unavailable". |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was very excited when I discovered Spook because I have so many times found myself reaching for a flatten filter that didn't exist when writing HA templates. I've started using it in various places and run into problems when I restart home assistant.
I tried using it in a restful sensor's
value_template
but I get an error when HA starts because it cannot find theflatten
filter which then disables the sensor.Similarly, I am using it in a script, but it also gets disabled after a restart because the filter isn't recognised. I can workaround this by tweaking the script and saving it, but it's annoying to have to do that after every restart.
Is there either a way to force spook to load before these other integrations, or to change the templates to fail more gracefully when flatten hasn't loaded yet?
Thanks in advance for any suggestions!
Beta Was this translation helpful? Give feedback.
All reactions