This post was most recently updated on March 16th, 2023.3 min read.
This article explains how to fix and reconnect Sonoff Zigbee sensors in Home Assistant, after they have mystically disconnected themselves.
The neatness of this solution is that while the eWelink app will assign your sensors a new device id any time you have to re-register them, this approach lets you use the same entity id you had for them before you had to reconfigure them.
They don’t unfortunately retain their historical values (through the UI anyway), but at least you don’t have to change your automations or templates. Yay!
Table of Contents
I’ve been a pretty active user of different Sonoff -branded devices, especially hygrometer sensors (for temperature and humidity) for a couple of years now.
I’ve had a couple of the sensors de-register themselves from my Zigbee bridges, however – a couple of times that has happened when a sensor disconnected because I either moved the bridge and the mesh couldn’t reach to the sensor anymore, or the sensor ran out of battery. And once or twice there’s just been a firmware glitch with the sensor, I suppose.
Whenever this happens, you’re faced with a problem. Even if you take the sensor right next to the bridge and start it up, it won’t reconnect. You can always readd it to the Bridge using the eWelink app, but that registers it as a new, completely unrelated device – and hence it won’t be associated with your stuff in Home Assistant properly.
But, as always – there’s a workaround!
This guide explains how to make sure your newly added senrsor has the same entity id in Home Assistant as the sensor did before re-registration. That way you don’t need to rename your references to the sensor in templates, dahboards and automations.
Time needed: 5 minutes
How to properly change the entity id of a Sonoff sensor after having to re-register it in the eWelink app?
- Re-add the sensor
First, you’ll need to open the eWelink app to add the sensors again. Just go through the usual motions. Don’t worry about it being a duplicate.
For clarity’s sake, use the same name as you did before. The device and the associated sensors will get a new id, but at least the name will help you identify it.
- Reload Sonoff integration in Home Assistant
This’ll make sure your Home Assistant adds your newly registered entities.
Reloading your integration in Home Assistant
- Find the newly added entity
You should now the name, so you should be able to find your new entity at this point.
- Remove the duplicate entities
If you got the name right, your entities should be nicely grouped by name, and the broken ones can be recognized by the handy errors.
You’ll need to remove the invalid ones so you “free up” the id of the entity to be used in the next step. You might want to copy the old entity id for your use in the next step, just in case!
- Change the id of the entity
You can’t change the id of a device – but you CAN change it for an entity! And you can just use the same name you had before.
So now you’ll need to open the settings for your newly added entity, and you can change the entity id to the one you copied in the previous step.
The device id that you see in the eWelink app will be different than the id the entity has, but I don’t think that has any negative side effects.
And there you have it. A straightforward way to make sure you don’t need to replace your entities names in a hundred automations and templates if you ever need to re-add them.
- Itead’s web shop for Sonoff sensors and gadgets
- The temperature & heat sensors on Amazon
- The temperature & heat sensors on AliExpress
The links to Amazon, AliExpress and Itead in this article are affiliate links, and if you buy something through them, I earn a small commission at no extra cost to you. Thanks for supporting the blog! 😄
- How to configure a custom 404 page for a SharePoint site? - August 22, 2023
- Azure DevOps pipelines suddenly failing with “##[error]#0 building with default instance using docker driver” - August 15, 2023
- How to fix Windows not recognizing your mouse clicks? - August 8, 2023