The new floors thing is cool. I want to know the median temperature reported by all temperature sensor entities on each floor. I have this so far:
{{ floor_areas("first")
| map('area_entities')
| list
| join
}}
This gives me a list of entity IDs on that floor (The join filter appears to flatten arrays which is fun). How would I turn that into a list of state objects? And how do I get the median from a list of numeric values? Ideally i want to do something like this:
{{ floor_areas("first")
| map('area_entities')
| list
| join
| map('states') # Doesn't seem to work
| selectattr('attributes.device_class', 'eq', 'temperature')
| map('state') # Doesn't seem to exist
| median # Doesn't exist
}}
Any ideas? I also considered approaching it from the other direction and finding all temperature sensors and then filtering for floor, but I can’t figure out how to use the floor functions in a selectattr, and I am not sure the floor is yet an attribute of a state.