Get device name from unique device ID

A number of my automations have ‘failed to set up’, but the error message just contains the entity ID.

e.g. Error:`Unknown device ‘6a63aff0108849a4a235a181283131e0’

Firstly, I wanted to check if these error messages would show the device name if one had been set?

If the error message doesn’t show the device name even if one has been set, is there a way to search - using the device ID, to get the device name?

Copy-paste the following template into the Template Editor.

{{ device_attr('6a63aff0108849a4a235a181283131e0', 'name') }}

If it returns null then it means Home Assistant can’t find a device with that id.

Reference

Templating - Devices

Thank you @123 that returned a ‘null’, which makes sense as the automation has failed to set-up because the device with that ID can’t be found.

My challenge is trying to figure out which device and / or trigger I originally used to set up the automation. Perhaps I should put a feature request in for the system to store the device name as well as the ID

If it’s null then the supplied device_id doesn’t exist so there’s no name for it stored anywhere.

One or more of your automations refer to a device that no longer exists by the device_id it was originally assigned.

The device was either removed from your system or replaced by another (which was assigned a different device_id).

For future reference, you may wish to review the following community guide:

You can use a text editor to seach the automations.yaml file for instances of the device_id. This will lead you to the appropriate automation(s).

My thanks again @123 .

I take note of the ‘best practice’ and will amend the automations as suggested

My challenge remains not having enough context with the error message to know what the original (now missing) devices / triggers might have been

I agree there’s not much of a clue as to where to look for the broken references. If faced with the same situation, I would do what I suggested above (search automation/script files with text editor).