I’d like to filter all update entities from HACS integration which do NOT contain something like <ha-alert alert-type='warning'>Requires Home Assistant.
What I have so far:
{{ integration_entities('hacs')
| select('match', 'update')
| select('is_state','on')
| selectattr('release_summary','defined')
| selectattr('release_summary','ne','<ha-alert alert-type=\'warning\'>Requires Home Assistant')
| list
| length
}}
This gives 0 at /developer-tools/template, without length I get [].
Because of annoying
one still needs to use | selectattr('release_summary','defined') before accessing the attribute, otherwise the dev tools section gives
According to the Studio Code Server “Generate Template” function, the | selectattr('release_summary','ne','<ha-alert alert-type=\'warning\'>Requires Home Assistant') is not respected.
The result of integration_entities('hacs') is an array of entity_id strings. While “select” supports this, I don’t believe “selectattr” does. Therefore you need to first use “expand”.
Then the HA attributes are under an attribute called “attributes”. Confusing, but it means you need “attributes.release_summary” instead of just “release_summary”.
And you’re “ne” match will not match anything, because it’s going to compare the whole string, not just the first part - so better to use “match” instead with “rejectattr” (assuming I following what you’re wanting to achieve).
Oh wow! I’ll give that a try immediately to see if it works. Many thanks in advance
Update: Gave it a try. Basically works great. It’s just the rejectattr part which needs a bit of tweaking (adding * wildcard to match all strings containing that search string, usually it’s a lot more text around that). In the end I used this:
With this template I now get the number of available updates from HACS integration (experimental features enabled), which are actually installed (no HA dependency issues).
@michaelblight I’ll therefore of course mark your post as (ultimate) solution - thanks a lot!
Would you mind taking a look at this too maybe? It seems like you’re a pretty skilled Jinja template pro …and this one is causing me headache for quite some time: