How to use device selector in templates?

My understanding is that the device selector only returns the device id, but how can I then use this to get the device name?

blueprint:
  name: test
  domain: automation
  input:
    phone_device:
      name: Phone
      selector:
        device:
          integration: mobile_app

variables:
  phone_device: !input phone_device
  phone_battery_level_entity: "sensor.{{ phone_device }}_battery_level"

What I want here is that for a device called “pedro_phone” created by the mobile_app integration, I want to get the “sensor.pedro_phone_battery_level” but it just translates to “sensor.a1b2c3d4e5f6_battery_level”

I tried the states object but as expected that does not work… am I missing something here?

2 Likes

Did you solve the problem?

Unfortunately, no… I ended up having an entity selector for the battery level instead… Not ideal but I guess the support for anything else is not there right now!

I need this too? Anyone figure out how to get it working?

I had posted this but now realize we’re asking the same question.