Home_Assistant_Integration icon indicating copy to clipboard operation
Home_Assistant_Integration copied to clipboard

Version 1.0.0 - Entity ID to Device ID

Open chunkysteveo opened this issue 11 months ago • 14 comments

If you're having issues with your automations and getting errors like Error: 'NoneType' object is not iterable - have you checked the breaking changes?! Service calls need to call the DEVICE, not the Entity.

You can easily update from entity to device in the automation GUI - but this may invalidate your YAML if the automation is complex. Updating from entity to device in YAML is trickier. You need to change the following:

    target:
      entity_id:
        - open_epaper_link.00000123ABC456DE

to:

    target:
      device_id:.THIS_IS_YOUR_DEVICE_ID

Easiest way I have found to find your device_id is to click on the tag device in the integration e.g. https://YOUY_HA_URL/config/devices/dashboard?domain=open_epaper_link , and click on the tag. This will give you the device ID in the URL to copy, e.g. - https://YOUY_HA_URL/config/devices/device/THIS_IS_YOUR_DEVICE_ID

Is there a better/easier way to get the device ID to copy into YAML automations??

chunkysteveo avatar Jan 05 '25 14:01 chunkysteveo

Of course this method only works in a browser. If you’re accessing HA via the app (on an iPad, say) then the URL isn’t shown so you’ve no idea of the device_id.

If that’s you, just open HA in a Safari window temporarily.

Shame we have to do this…

PaulOckenden avatar Jan 06 '25 09:01 PaulOckenden

Of course this method only works in a browser. If you’re accessing HA via the app (on an iPad, say) then the URL isn’t shown so you’ve no idea of the device_id.

If that’s you, just open HA in a Safari window temporarily.

Shame we have to do this…

Yeah, noticed that too if you have the Windows 'app' installed - it's a browser window that's in kiosk mode, so no URL either.

chunkysteveo avatar Jan 06 '25 10:01 chunkysteveo

You can also use Developer tools > Actions > OpenEPaperLink: Draw Custom Image.

Choose you tag and switch to YAML mode.

jurasjo avatar Jan 06 '25 13:01 jurasjo

I'm finding this suggested way of specifying the device_id is not working for me :-?

Script is unavailable Actions: expected a dictionary for dictionary value @ data[0]['target']

Looking at the script in the UI in YAML mode, it's merged the target/device_id line after importing the script. ie in the script I have:

    target:
      device_id:.<MAC>

But this turns into the following after reloading scripts:

    target: device_id:.<MAC>

Jim-Noble avatar Jan 06 '25 21:01 Jim-Noble

I'm finding this suggested way of specifying the device_id is not working for me :-?

Script is unavailable Actions: expected a dictionary for dictionary value @ data[0]['target']

Looking at the script in the UI in YAML mode, it's merged the target/device_id line after importing the script. ie in the script I have:

    target:
      device_id:.<MAC>

But this turns into the following after reloading scripts:

    target: device_id:.<MAC>

It's not the MAC, it's the device ID that Home Assistant assigns to the tag.

chunkysteveo avatar Jan 06 '25 22:01 chunkysteveo

I really don't like the change. Optional (so that both ways are supported) o.k., but mandatory? I'm not using devices anywhere. Because it is so hard to replace them. There are a lot discussions around it. If I want to replace a device with another, I just have to set the entitiy_id to the one before and be done everywhere. In UI, in automations, in scripts, ... With device_id, I have to rework everything.

This is really not a good idea to force this here in this single integration. I don't have any other integration or service-call in use, where only device_id is allowed.

emufan avatar Jan 07 '25 07:01 emufan

I really don't like the change.

Agreed. I did eventually make it work in Node-RED using the lookup method suggested by @jurasjo upthread. But still a royal pain..

This is really not a good idea to force this here in this single integration. I don't have any other integration or service-call in use, where only device_id is allowed.

This, and the fact that my devices are now littered with unavailable entities, has me reverting this integration. Sigh.

Boh1 avatar Jan 08 '25 16:01 Boh1

Hey, thanks for posting this. I spent way too long trying to debug this. I'm a little irritated that you can't easily lookup the device_id. I shouldn't have to use the Developer Tools GUI to find the id. This change will also be more difficult for me to troubleshoot. I have one automation that sends the same weather information to 3 different tags. If I have an issue with a tag I have to go lookup the device_id and figure out which Tag MAC it matches. It was nice to just scan the barcode on the tag to identify the entity_id.

smaegley avatar Jan 15 '25 21:01 smaegley

Yeah, i agree. I'd like to see the ability to target the entity again, or ability to know the device better??

chunkysteveo avatar Jan 16 '25 01:01 chunkysteveo

I did discover an easy way to find the device_id. To get the Device ID:

Goto settings -> Devices then click on the device. Click on the device Click on the plus button in Automations. Click on "Use device as trigger". This will open the automation editor page. Click three dots, choose “Edit in YAML” - you will see device_id and entity_id of this device. Don't save the automation, just exit the editor.

SteveRMann avatar Jan 16 '25 05:01 SteveRMann

@g4bri3lDev You did these changes from using entity_id to device_id, didn't you? Can you jump in and explain, why it was necessary or why did you do it. At least with supporting the entity_id as well in the service calls as well and as it is usual in nearly every other service call I know?

Can you please make the device_id-way only optional and bring back the entity_id way?

emufan avatar Jan 16 '25 06:01 emufan

@g4bri3lDev You did these changes from using entity_id to device_id, didn't you? Can you jump in and explain, why it was necessary or why did you do it. At least with supporting the entity_id as well in the service calls as well and as it is usual in nearly every other service call I know?

Can you please make the device_id-way only optional and bring back the entity_id way?

This isn't my repo, I only raised this issue to highlight how to change people's YAML in automations. I'd recommend raising a new issue requesting having device or entity options, or finding a new/better way to target tags in the automations?

chunkysteveo avatar Jan 16 '25 08:01 chunkysteveo

@g4bri3lDev You did these changes from using entity_id to device_id, didn't you? Can you jump in and explain, why it was necessary or why did you do it. At least with supporting the entity_id as well in the service calls as well and as it is usual in nearly every other service call I know? Can you please make the device_id-way only optional and bring back the entity_id way?

This isn't my repo, I only raised this issue to highlight how to change people's YAML in automations. I'd recommend raising a new issue requesting having device or entity options, or finding a new/better way to target tags in the automations?

Sorry!! Just noticed you were tagging the author, not me!!!! It's too early for me here! Haha

chunkysteveo avatar Jan 16 '25 08:01 chunkysteveo

I did discover an easy way to find the device_id. To get the Device ID:

Goto settings -> Devices then click on the device. Click on the device Click on the plus button in Automations. Click on "Use device as trigger". This will open the automation editor page. Click three dots, choose “Edit in YAML” - you will see device_id and entity_id of this device. Don't save the automation, just exit the editor.

I found a simpler way: you can locate the device id from the url of the device page

krikkirk avatar Jan 19 '25 19:01 krikkirk