Context:
I’m running Home Assistant (as well as a number of other apps) on TrueNAS Scale.
The TrueNAS integration surfaces a binary_sensor for each deployed app in Home Assistant with several extended attributes, such as “Update available”.
I’m trying to build a single, dynamic, binary sensor to flag when any deployed app has an update available.
Code
For a single app, the following:
{{ states.binary_sensor.truenas_apps_home_assistant.attributes["Update available"] }}
Returns True/False based on the value of “Update available” (great!)
I’ve then expanded this logic out to search for any binary sensor where the entity_id starts with “truenas_apps_” as follows:
{{
states.binary_sensor
| selectattr('entity_id', 'search', 'truenas_apps_')
| selectattr('Update available', 'eq', true)
| list
| count > 0
}}
This always returns False
Further testing explains why:
{{
states.binary_sensor
| selectattr('entity_id', 'search', 'truenas_apps_')
| map(attribute='Update available')
| list
}}
This simply returns the following array: [Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined]
It seems that the issue relates to referencing an attribute with a space in the name. I’ve tried replacing the space with an _ but it makes no difference.
I’ve done some digging around and can’t seem to find a solution. Any suggestions for how I might get this working would be gratefully received.