deCONZ - entity ID assigned by integration after re-adding

Hi there,
I have an existing deCONZ integration in my setup, using the deCONZ plugin from the store, which works just fine.

When I add a new device, let’s say Motion sensor to the Phoscon app, I name it right in there as “Bedroom Motion” this gets propagated to the integration where I can find an entry named Bedroom Motion, but when I look at the entity ID it says for example “binary_sensor.presence_27”, which would be fine if it stayed like that. Now if I for some reason have to remove the integration, then I re-add it again, the entity ID says “binary_sensor.bedroom_motion”. Now it stays like that no matter how many times I remove and add the integration.

This messes up my automations if I specify the “binary_sensor.presence_27”, I would much rather have the entity ID generated by the name, which doesn’t change. Do I have to delete and readd the integration each time I add a device before using the entities in automations? Or is there a better way to make it “catastrophy” proof in case I need to reinstall the deCONZ?

You can change the entity id if you want

I know I can change it manually, however even if I change that manually, there is no static identifier between deCONZ and HA, so if I remove the integration, those changes get wiped out, and after readding it back, it will get overwritten to default by deCONZ ID (for example binary_sensor.bedroom_motion) again, so I would have to manually change it to the ID that deCONZ would assigned after readding the integration based on the name. It looks like it is using snake case to determine the entity ID, but it just creates more room for a mistake in more complex names.

So if you delete the integration all entity registry entries will be removed, thus requiring regeneration upon next setup of the integration. The integration will base the entity id on the name in deconz. If you are running home assistant automations you can use device automations rather than ordinary entity ids which will not hard code a specific entity id.

But as the doctor would say; stop removing the integration :slight_smile:

There are several problems here

The deconz integration should not load new devices until you tell it to. Or at least delay it. You will always rename new devices in Phoscon if you are a normal person, but Home Assistant loads the new device the minute it is paired and then ignores any renaming. The new devices should be loaded with the same you assign in Phoscon. The whole workflow is poor the way it is implemented now.

Not removing the integration is a poor solution. It is still the only UI way to remove a device. You still cannot delete individual devices. Or you have to learn to hack the device json file in .storage which. It is only two days ago a Philips smartplug broke and I had to replace it. With more than 80 zigbee devices you must expect to replace broken devices mang times per year. When I added the new device the old one was still there and name clashed with the old now broken device. So I renamed the old device to a dummy name and renamed the new device to the old name but still HA blocks the ability to rename the new entity to the old entity name which you need to do, unless you want to edit several automations and Lovelace cards. So AGAIN I had to hack the JSON file to get rid of the old broken device. We need a way to delete a device without deleting the whole integration.

And do not get me ticked with that current implementation of device automation feature. The idea is good and it looks good on the surface. But it is implemented so it only really only works in the automation editor and is based on random very long device IDs that no normal human can work with in manual automations. It should have been based on human readable entity IDs. And imagine working only in the automation editor. Imagine it when you, like me, after one year, have almost 300 automation neatly organized in multiple folders and files. I am sure it will be better later but right now the automation editor is only good for simple automations and less than 20-30 of them. And migrating from the editor to manual multiple yaml files is tough when the automation.yaml file get full of device IDs that are random long numbers.

I think sooner or later you will have to remove and readd the integration no matter what. It already happened to me that few of the devices were not propagated through the integration from deCONZ and I had to remove the integration and readd it again to read all of my devices.

Also device automations are good, but as Kenneth said, it’s not only automations, it was just an example, I am mostly using NodeRED for the logic, and that has to use the entity id.

I know it should happen only in rare cases, but I want to make it as crisis proof as I can, instead of spending many hours integrating everything, then pulling my hair out that one day when it crashes :grinning:

That’s what I was thinking was the problem, that the device is added to the integration as soon as I add it to Phoscon, so I have no time to update the name, it would be nice to have some kind of manual Sync button in the integration, so I could set the name properly in the Phoscon and then manually sync it to HA with correct entity ID based on the name, which wouldn’t change as long as the device is in the Phoscon app.
You pointed out some good real life scenario with the broken smartplug.
Do you think it would work if you added the new plug, renamed the old one in Phoscon to some dummy name, then rename the new plug to the old name, remove the integration and readd it again? Would the HA integration assign the same entity ID to the new plug based on the name from Phoscon? Or would it compare the device ID, found that it is different and add it as a different entity ID?

If this would work I think it might be best (at least for a new installation) to actually remove and re-add the integration each time new device is added to keep everything set to the device name based entity IDs from Phoscon.

@InToSSH the thing you can do each time you add a device from Deconz is.

  1. Rename device in Phoscon to something you like to keep.
  2. Rename right away after it is imported into Home Assistant the device name as well as all entity names to the name that the deconz integration in HA would have assigned if it has been named like this from the beginning.

I personally run my deconz in bare metal and not as an addon so it is easy for me to stop Home Assistant completely and then open Phoscon to add devices. This way I get the chance to rename the device in Phoscon before it gets pulled in. But I sometimes forget and then I go through the devices and entities and names them using the same rule as Home Assistant does. And this means giving the device exactly the same name as in Phoscon and rename the entities using the all lower case and spaces changed to underscore. I actually think HA now suggest this renaming now. This way the devices should load to the same names when you delete and re-add the integration

Even with the addon I think you can stop and start the HA docker and still keep the Deconz addon running. I just never tried because I prefer the bare metal (which has spared me a lot of the trouble people had lately)

@KennethLavrsen That’s a good idea. I will probably do the same thing. I have one unused RPi3 laying around and I need to move the ConBee to a more central location of my house to reach all of the devices without using a repeater, so I will dedicate the RPi just for a ConBee…

I guess for the future use I will rename the entitites manually to the name it would get from the Phoscon as you suggested. Now I am just at the beginning so it was faster to remove and re-add the integration when I was adding around 10 devices at a time, it was faster than renaming all entities manually.

Thanks for the suggestions

Give me some good logs of web socket events of you guys deleting devices and Ill make sure to support removing entities from hass when devices are removed from deconz

@Robban Devices! Not entities

The problem is very very straight forward. There is no way you can delete a DEVICE.

Once added it stays forever unless you delete the entire integration. Or hack the JSON file. There is nothing special to look for in logs.

Delete a light bulb in Phoscon. And then try and delete the light in Home Assistant. You can delete Entities related to the device if it is unavailable. But you cannot delete the device itself. It is not only Deconz that has that problem. It is the same with device trackers etc. Once a device is added there is no user interface to delete it again. It stays as cruft. And the problem besides being cruft is that it prevents adding a new device with the same name. Then you have to rename the old to some garbage name and restart Home Assistant.

The two typical normal everyday use cases are

  1. I have a Zigbee device that I no longer need. I remove it in Phoscon. I want it removed in Home Assistant.

  2. I have a Zigbee device that is broken. It is dead or unstable. I want to replace it with a new similar device. I remove the old from Phoscon and I add a new giving it the same name as the old. And the end result I want is that things work like before the broken light bulb was replaced. I want my Device name and the Entity names the same as before.

The latter case is what gives the most grief. The old Device and the new Device are both in Home Assistant now. The new device will have entity names autogenerated to be _2 appended.

So you can go to the old device and delete the entities. And then you can rename the new entities by removing the _2. Well actually you cannot until you have restarted Home Assistant. You end up with something working with these extra steps. But you still have that old original Device record in the JSON and it still shows up as a device when you look at thr Deconz integration. The only way to get rid of it is to stop Home Assistant. Edit the .storage/core.device_registry JSON file. And then start Home Assistant again.

The elegant solution will be that removing a device from Phoscon also removes the Device in Home Assistant. But that may be dangerous for the edge cases where people need to remove and readd the integration. Be careful with that.

I would personally be happy if the UI of Home Assistant had a delete link for Devices the same that is already implemented for Entities.

@Robban @KennethLavrsen

Deleting devices is a feature I still miss

1 Like

Adding another use case for this ‘delete’ functionality: I recently added a new Ikea blind to my Zigbee network.

I stuggled with the initial integration due to running a specific version of the Conbee software that has some issues with the Fyrtur blinds. I got the device detected in HA via the Deconz integration on API entry light/6. But since the Zigbee blind was not working as expected with that specific Conbee II firmware on the USB stick I had to update to a more recent version. After the upgrade I re-linked the blind with the Zigbee network and it got assigned a new API entry point light/8.

However, since HA initially detected the API entry point for this blind to be light/6 I cannot control the blind from HA as it keeps referring to the device via the original API entry point resulting in this error:

/lights/6 resource, /lights/6, not available

when I try to execute a command.

If I could ‘forget’ the initial entry of the blind I would be a happy camper…

…so is there any way to rename device? I changed device name in Phoscon, but in HA is something different.

I came here wondering the same. It appears so. Goto configuration->devices->(select device with old name) -> ->(change to new name). This new will only be unique to home assistant and any rules or automations will need to be updated.

So have any of you looked into ‘deconz.remove_orphaned_entries’

Check the bottom of this thread:

There is also a new option for deconz integration that disables automatic additions of devices meaning you can add your device to Deconz and name it properly and then call the device refresh service to add new devices to the integration