Template for a related entity

I’m trying to average a collection of sensors filtered by their state.
however it turns out the data I want to average isn’t an attribute of the state entity, but a related entity.

This I thought was going to give me a list of all valve openings of all my TRV’s that are enabled (in heat mode).

"{{ states.climate| selectattr('state', 'eq', 'heat')
                    | map(attribute='valve_control')
                    | list }}"

it turns out though that my device entity is made up of related entities.

does anyone know how I can traverse the parent entity to a related entity?

According to the documentation, you can list all entities related to a device using device_entities.

Thanks @123 .

I’ve read that before, and I could have read it another 10 times…

I’ll see what I can do, thanks for pointing it out.