Is it possible to autofill entities from a device?

I have this blueprint I created which I require the user to provide the entity for each sensor.

But the Apollo Air Esphome gives you an “Apollo Air” device that has all the entities underneath it.

My question is, can I design the blueprint in such a way, that the user only needs to specify the “Apollo Air” device, and the entities will be automatically grabbed from the device?

I can think of 2 ways I’d want to implement that:

  1. Set the default value of the entity input, for example, the “temperature sensor” default value will be grabbed from the provided device, with the option to change it if the user needs it.
  2. There will be no need to specify an entity for each sensor, and the blueprint will only use the specified “Apollo Air” device. (But then what would happen if the user renamed one of the entities to a custom name?)

Any help would be appreciated!

Hello Tomer Horowitz,

You should be able to use the filtering in the entity or device selector to get just what you want.

Did you figure this out? I’m trying to create a blueprint for MSR-1 where I turn on its rib light based on its reading for CO2 level and it seems weird to have to select entry of the light and then the co2 sensor in separate inputs vs just selecting the sensor (MSR-1) itself only once.

I don’t have the device in question, but it should be possible as long as you can insure that the sensor entities are determinable by either their entity ID or one of their attributes:

variables:
  device_id: !input apollo_device
  entities_list: "{{ device_entities(device_id) }}"
  pm25_sensor: "{{ entities_list | select('match', 'sensor') | select('search', 'pm25' ) | first }}"
  humidity_sensor: |
    {{ entities_list | select('match', 'sensor') | expand | selectattr('attributes.device_class', 'defined') | selectattr('attributes.device_class', 'eq', 'humidity') | map(attribute='entity_id') | first }}