Easy way of swapping current devices for new ones?

Hey all,

I’m curious what everyone’s method is for integrating a new device into your home assistant; a device that will replace a current device already installed (and automated and scripted).

When I am in the process of replacing a device with a new one, I can’t name the new device the old device’s name because it is already taken. Thus, I have to delete the old device, and then rename the new device. However, this causes my automations that included this device to lose this device’s reference, causing me to have to go into each automation/script to fix the device reference.

Does anyone have a better method of swapping devices in HA, without negatively affecting your automations/scripts?

1 Like

Just went through this a couple days ago. I copied the old device name, then deleted the device. I already had the new device discovered, so I rename the device and allow the UI to rename the entities. Usually have to trim the entity names a bit to match the old, but it went pretty smoothly.

I’ve also renamed the old device so I can rename the new device to what I want.

1 Like

This didn’t affect your automations or scripts that used the deleted device?

No, I made sure that the entities matched what the old one was.

Don’t ever use device automations (use the other trigger/condition/action types, ones that don’t require a device_id) and you will find it is a lot easier.

Tom,

I’m not sure what you mean by the “use the other trigger/condition/action types”. Can you clarify?

Currently, there are 2 ways that I see to send a device action.

  • action type: device, then select your device and action
  • action type: call service, select service, then select device.

I seem to use both methods for no particular reason. I believe the ‘action type: device’ method is the one that I need to update after swapping a device.

Don’t use the first method you listed, if you want to be able to easily replace things.

1 Like

I don’t use them so I could be wrong but…

doesn’t the second method also use a device just in the service data for the action?

if in method two they would have instead said…

  • action type: call service, select service, then select entity.

…I would agree.

so to the OP the point is don’t use a device_id anywhere in your automations, etc or you will have trouble with replacing devices.

It does. I missed that.

So yeah, don’t do either of those things Daniel. Do what Finity said.

1 Like

Correct me if I am wrong but my understanding is this:

When calling a device in automations, scripts etc, your are calling the device ID that is set automatically in the backend, this device id will always be unique to the actual device and as such has no relevance to what you actually name the device in HA front end, so renaming the device has no affect and therefore in the OP’s case if automations reference the device (name) then they will all require changing to represent the new device regardless of name.

However the entity id’s / name can be freely and easily changed in the front end, therefore best practice would be to use the state of the entity as a trigger for example, that way as long as you change the names of the entities to match those of the old ones being replaced then no affect is placed on any automations, scripts, Lovelace etc.

1 Like

Yes that is correct. You can change the entity_id in one place to match the old one. You cant do this with device ids. So if you have used device ids in your automations and scripts you have to change them everywhere they have been used.

Not a huge chore with a good text editor’s find and replace function, but still more difficult than changing one entity id.

That look likes to be the issue. I have changed all my automations that used ‘call service, select device’ to be ‘call service, select entity’ now. Thanks!

3 Likes

I am also in the process of upgrading some of my plugs to new ones. Am I reading this thread right, that there is no way of transferring an old device to a new one?
In my case I would like to keep my energy consumption in the energy dashboard consistent. Otherwise I will have to drag on my old devices for legacy measurements (and thus duplicate everything…).

Yes you can. Just point to the entity, not the device id.

1 Like

Sometimes people with tons of experience only need two keywords.
I am not that person. It is so useful when someone else writes the problem/solution in his own words.
So thank you!