Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flatten not consistently working for template sensor #762

Open
DarthSonic opened this issue May 12, 2024 · 2 comments
Open

flatten not consistently working for template sensor #762

DarthSonic opened this issue May 12, 2024 · 2 comments

Comments

@DarthSonic
Copy link

What version of Spook are you using?

3.0.1

What version of Home Assistant are you using?

2024.5.3

The problem

I created a template sensor in configuration. yaml. I am using flatten within the state template. When loading the yaml in developer tools, everything works. When restarting HA, the sensor gets unavailable and error log shows that flatten function is unknown.

Is there a way to overcome that issue?

Anything in the logs? Paste it here!

No response

@caphm
Copy link

caphm commented Aug 8, 2024

I've got the same issue. I'm using flatten filter in a template within a script. Home assistant disables that script because it claims it could not be validated:
„invalid template (TemplateAssertionError: No filter named 'flatten'.) for dictionary value @ data['sequence'][1]['variables']['result']. Got '{{ { "entity_id": (entities + areas|map("area_entities")|flatten + labels|map("label_entities")|flatten)|unique|list } }}'“.

@Phileep
Copy link

Phileep commented Jan 17, 2025

I have the same issue with the shuffle helper being used in scripts.

After restart, the script is disabled as invalid due to shuffle being used.

relevant log excerpts:

2025-01-17 08:32:43.613 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration spook which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2025-01-17 08:32:43.615 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration spook_inverse which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2025-01-17 08:34:24.252 ERROR (MainThread) [homeassistant.components.script] Script with alias 'dont stop the music' could not be validated and has been disabled: invalid template (TemplateAssertionError: No filter named 'shuffle'.) for dictionary value @ data['sequence'][0]['variables']['artist_list']. Got '{{ (( state_attr("input_select.music_artists_favourite","options")  |  shuffle | list )[:(number_of_artists - random_artists_tracks )]  + ( state_attr("input_select.music_artists","options")  | shuffle | list )[:(random_artists_tracks )] | shuffle) }}\n'

Running spook v 3.1.0 installed via HACS.
Home assistant core 20251.2

To get it working again I need to touch the script and then it usually will validate ok and work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants