Physically replace failed device

Does Home Assisntant support “easy way” to replace failed device?
My Aqara Bulb (lamp) fails (was broken).
This device used in many scripts and scenes.
I bought new bulb.
Now i need to rewrite all the scripts with new device address?

Only if you used device triggers, conditions, or actions.

And you don’t have to re-write everything. You just need to change the old device id for the new one. Everywhere you used it.

A text editor with a good “find and replace” action should help with doing this.

In future only use entity_ids, not device ids. You can change the new entity_id to match the old one in one place.

Cool! Yes, i can.
Can my mom or grandma or “an ordinary citizen” do it?
Does HomeAssistans team have any plans to make this function user-friendly?

1 Like

I posted this 2 years ago:

There is also a related WTF post.

Due to the lack of movement on this I suggest your mom or grandma not use device automations as instructed above. Hopefully they should be able to change one entity id.

Where is entity_id ?

To change it, go to Settings → Devices & Services → Entities Tab.

Click on the entity. You can edit the entity id in the pop-up box.

This will not change other places that you have already used the entity id.

Hence it is only useful for making entity ids more understandable if you have not used them yet (do it soon after adding them), or for changing a new entity to match one that is no longer available.

What’s this?
I gave this name on the low-level (zigbee gateway).
And the gateway translate it to Home Assistant.
Can i use it in my scripts, triggers, … ?

It is the friendly name.

No you cant use it in your triggers. It has to be the entity_id or device_id.

You can edit this name to be something more meaningful to you in the same place I listed above. It can contain capital letters and spaces (the entity_id can not) to make it look pretty in your dashboard cards.

Hi, what about buttons as triggers? In my case button entity has no options to recognize single, double or long action. It this a case when a device must be used?

Use an event trigger. https://www.home-assistant.io/docs/automation/trigger/#event-trigger

Thanks a lot for your prompt response. I’m not sure if I followed it correctly, but the below configuration actually worked:

platform: state
entity_id:
  - sensor.btn_kitchen_desk_action
attribute: action
to: single
id: btn_kitchen_desk_single

The only inconvenience is that when editing in GUI, there is no hint on valid FROM / TO states. You must type “single” manually, while when using a device as a trigger the valid options are suggested by the GUI. It is intentional or maybe possible improvement?

That is a state trigger. Which I did not suggest because you said:

Clearly it does have this option.

Sorry for confusion, I’m just beginning my HA journey and do not recognize it all properly yet. I was mislead by the fact that when use state trigger its possible values are not suggested by the GUI - like they are when device trigger is used. Anyways, thanks for your help.

I need to replace a few bulbs that are faulty at home. It made total sense to me renaming the new bulb so it got the same entity_id. At least in theory, when I went about adding the new bulb I realised I cannot give it the same name as a bulb that already exists.

I tried stopping the z2m addon in home assistant, replace the bulb and remove the info of the old bulb the z2m configuration before starting it back up.

In the devicelist of z2m I then had the old one still, now with the ieee(?) adress and silly me removed it before checking in home assistant… :exspressionless:

When I went to entities in home assistant it looked like this:

So I foolishly renamed the bulbs entity_id in home assistant. Which led to me having two (2) bulbs, one named light.vega and one called light.vega_2. No screenshot of that…

Starting up again the entities look like this:

Should I try to rename the remaining entities or just remove the bulb and start over?

The old bulb is removed from the scenes and I can live with that, I just want to learn how to go about this a better way for the remaining bulbs. Please explain it to me as if I’m five, I’m really doing my best to grasp this.

I’m deploying a lot of 1-wire sensors so I’m wrestling with how to make it easy to replace failed units down the line, or temporarily swap one out with a different one (e.g. to check calibration). What I’d ideally like to do is create a “logical” ID for a sensor based on its purpose (e.g. water heater inlet temperature) and refer to this in all scripts, automatons, templates, cards, Node Red, whatever, and map that to an ID that’s used to physically access the entity.

On its face, this would seem to be what entity IDs vs. friendly names would be for. But the way HA allows me to use them seems to be just the reverse of that. Entity IDs are pretty much universally allowed but friendly names can’t be used in things like scripts, triggers, etc. For 1-wire entities the default entity IDs are useless for anything except physical addresses.

Old school template helpers with some code to help manage them seems to come closest to enabling the logical<->physical mappings I’m looking for in a somewhat manageable way. I haven’t explored “labels”, “tags”, or some of the other stuff that’s been added.

If HA supported defining “aliases” for entities and allowed any alias for an entity to be used just like an entity ID, with programmatic access to managing the aliases, that would probably cover all the use cases I saw in this thread, and mine as well. The friendly name could still be the “face” of the entity shown by dashboards.

FWIW, I saw that Paulus posted some musings recently about solving the even more general problem of how entity/device/room/area/label/… metadata gets contorted to serve needs much more general than the ones they were originally intended to serve. It’s a real issue. I sense there’s an elegant solution that will simplify a lot of things in HA but I can’t articulate it yet. Even though “alias” support would just tangle the net more, it would help before the swamp gets drained.

Friendly names are for display in your dashboards.

Entity ids are what you want to use to reference the device.

Delete the old device, add the new device and change the entity id to match the old removed one. That will ensure data continuity and your scripts and automations will continue to work as long as you only use entity ids not device ids in them.

See: Why and how to avoid device_ids in automations and scripts