Is it possible to do something along the lines of:
{% for sensor in platform['london_underground'] %}
{{ sensor.entity_id }}
{% endfor %}
The problem I have is that I need to know how many lines do not have a state of ‘Good Service’ but the sensors created by this platform have no way of isolating them (e.g. they do not have any common pre or suffix in their entity_id)
Yes I could check each one individually but there are 14 of them so it’d be nice to do it in a loop.
Rather than debate the differences between your two posts, I’ve chosen to retract my responses. This is for the best; they clearly missed the mark given that you felt the need to ‘defend’ yourself.
@123 Hey, you didn’t need to do that. I thought I made it obvious I was grateful for the solution.
I just didn’t understand why you thought I’d changed the question.
I’m sorry if I offended you. It was certainly not meant.
@petro no, nothing unique… I actually think they are particularly badly named sensors but I think it is too late to expect that to change.
It’s iterating through all sensors, you have to check to see if it exists before accessing it. In the past, this was silently ignored, now it’s raised as an error.
{{ states.sensor | selectattr('attributes.attribution', 'defined')
| selectattr('attributes.attribution', 'eq', 'Powered by TfL Open Data')
| selectattr('state', '!=', 'Good Service')
| list
| count > 5 }}