I’m trying to develop some template sensors that will provide how many lights are on in an area, for example. I have an area with just three lights in it for testing purposes:
As far as I can tell I’m using the select filter correctly. I’ve been digging around in the docs (which show what I think are similar examples) and I cannot understand where that error is coming from. One of the three light entities happens to be unavailable, so I added a filter to remove it, but the same error still happens:
I believe the problem is that the first argument to is_state is an “entity_id” string or array of strings. However, you are piping the output of selectattr, which will be an array of entity objects (once the generator generates them). Therefore you could do it after you use map to get the “entity_id”:
What @michaelblight showed works. Alternatively, just use it in a selectattr statement on entity_id. It works just like the in Jinja test you’re already using that way:
There’s no need for the template to begin by filtering the entire light domain. It can start with all the entities in the area itself and then select by matching the domain(s) you want.