Physically replace failed device

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.