How to cleanly replace/move devices?

What is the best way to replace and move a device in home-assistant?

I have one physical device (temp sensor), that i want to replace with a new physical device (better sensor, more values), while moving the old physical device to become a new device in home-assistant (temp sensor different room). Ideally while retaining previous data at the old position.

I have done it in the past simplty by removing and re-adding the device in the integration with a different name. But realized since that some of those got mixed up, with both (old and new) devices under the same name. I guess it remembered the devices unique id and re-mapped it somehow.

Is there a proper/clean way to do this?

A lot depends on:

  1. What are they, how are they integrated?
  2. Whether you fell for the trap of device triggers/conditions/actions or not

If those are Zigbee sensors then some won’t reconnect to the mesh if you move them out of range of their parent.

If you didn’t use the device then you can just change the entity_id and carry on happily. If you did then you’ll have to update all the automations.

Thanks.

In this case it’s a homematic-ip device. In the past i had the issue/mixup with shelly devices.

I have one trigger on the device to be changed, nothing complicated and would be easy to change to re-do afterwards.

Since a device has multiple entities, should i update/change all of the device to be moved? Then add the new device to replace the “free spot”?

The point being made is the distinction between “device” and “entity”. If you write automations for entities, then you can safely rename the entity id. As an example, assuming you are going to replace the bathroom sensor with a new one, and move it to the bedroom. If the temp entity was called “sensor.bathroom_temperature”, you can rename it to “sensor.bedroom_temperature” and then call the new one “sensor.bathroom_temperature”. Any existing automations referring to “sensor.bathroom_temperature” will now reference the new device, and the history will be retained. There is no need to remove & re-add the devices.

Obviously to do this you woudn’t want to orginally set up the device as “Bathroom temperature”, as having the temperature entity now being called “sensor.bedroom_temperature” would be very confusing. For this reason, I set up all devices as a generic name that reflects the app they’re registered in (eg. “Tuya Temperature 7”) and then rename the entities within to match their actual usage (which may change over time).

1 Like