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.
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.
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).