So providing a state object itself, something like: is_nominal(sensor.test) or is_nominal(sensor.test.attributes.attr)?
Issue with that would be that one would get an error if the state object does not exist.
{{ is_nominal(states.sensor.test) }}
{{ states.sensor.test is is_nominal }}
State object, for the intended use case in a generator as a test. I can help you set this up in your PR if you need me to. EDIT: Looked at your PR, looks like you got this part figured out so these following test cases should work. You have to use at least 1 select or selectattr in your test case because that doesn’t work without pass_eval_context and if someone changes that it’ll break select, selectattr, reject and rejectattr
{{ states | select('is_nominal') | list }}
{{ states | selectattr('state', 'is_nominal') | list }}
{{ states | selectattr('attributes.attr', 'is_nominal') | list }}
I’ll include myself in that group of “don’t know” when it came to understanding the meaning of the word ‘slug’. Entity_ids are slugs. It took a quick googling to learn what that means in the context of software terminology.
There’s a filter available to convert a string to a slug and it goes by the amusing name slugify.
It should do all of them. The goal is to shorten syntax in all the use cases where ‘unknown’ and ‘unavailable’ need to be checked, which is selectors and if statements.
{{ states | selectattr('attributes.attr', 'is_nominal') | list }}
If the attribute does not exist for an entity then it fails in rendering the template itself resulting in also those without the attribute being added to the list. Does not even get to the is_nominal function.