Xiaomi Gateway - switch.plug_##### random rename

The correct JSON is this

{ “device_id”:“158d0001a3xxx”, “gw_mac”:“f0b429aaxxx” }

the mac of the device and the mac of the gw, now restarting

I have around 30 xiaomi devices, all renamed … this is not good. I have to re-pair to the gateway, all of them???

Not good not good, this is a huge pain in the xxxx

@anon35356645 What happend in detail?

All Xiaomi devices got _2 in entity name. Breaking everything

and the HASSIO tab disappeared too …

Be careful. Do you own multiple devices? If not please disable the netdisco auto discovery (discover). The duplicates will disappear again.

I have 2.

I took out discovery (not discover, typo??) , and problem is the same

Hmm… if you plug off one of the gateways and reboot home assistant. Does the duplicates disappear? I want to make sure your devices really moved from one gateway to another. You could also enable debug output and provide the “get_id_list_ack” responses of both gateway. Does both gateways advertise the same device ids?

No, they stayed with its gateway, simply HA put a _2 on all the entity_id

how you get this?

Enable debug output:

logger:
  default: warn
  logs:
    xiaomi_gateway: debug
    homeassistant.components.xiaomi_aqara: debug

Reboot hassio. You will find the keyword in your home-assistant.log afterwards. One per gateway hopefully.

In my original scenario I actually added the device to the second gateway before removing it from the first. It was self inflicted, not something that just happened…
Hopefully there is a simple explanation and fix for Claudio.

I’ve seen this issue manifest itself, but in a slightly different set up.

I have a single gateway, and have been flipping between running two docker images for HA. I never run both images at the same time, only one at a time (with a full stop/rm of the container each time). Both use the same underlying configuration.yaml (with discovery off).

The container images are largely the same except one runs off an alpine base so the footprint is smaller.

When starting one image, xiaomi device id’s are as expected. If I stop/rm it, and fire up the other image the device id’s have “_2” appended. I’ve stopped and started the containers numerous times and always get this behaviour.

Been looking at pyXiaomiGateway, but can’t see anything that stands out. Was wondering if there’s some sort of session or identifier that’s confusing the Gateway into thinking there are multiple HA’s or multiple devices of the same Id.

Ok further to my comment above. I waited a long time between switching docker images (so instead of stopping one and starting another a minute later, I waited several hours).

The “_2” has now gone from the container that was experiencing that issue.

So, from what I’m experiencing (may not be directly related) it does look like a session of some sort is causing the issue between my two container instances of HA (that run the same configuration.yaml).

I have the same problem with HA 0.84 and also with the version 0.85 beta 1. Has anyone solved it?

@maramazza Could you provide the content of your .storage/core.entity_registry? I’m interested in both sections of the plug. Something like this:

# first entry
            {
                "config_entry_id": null,
                "device_id": null,
                "disabled_by": null,
                "entity_id": "switch.plug_158d00012a9aa5",
                "name": null,
                "platform": "xiaomi_aqara",
                "unique_id": "status158d00012a9aa5"
            },

# second entry
            {
                "config_entry_id": null,
                "device_id": null,
                "disabled_by": null,
                "entity_id": "switch.plug_158d00012a9aa5_2",
                "name": null,
                "platform": "xiaomi_aqara",
                "unique_id": "???"
            },


My problem is a bit different…
I have all the sensors with the name XXXX_2
For example…

{
“config_entry_id”: null,
“device_id”: null,
“disabled_by”: null,
“entity_id”: “binary_sensor.door_window_sensor_158d0001e46f39”,
“name”: null,
“platform”: “xiaomi_aqara”,
“unique_id”: “status158d0001e46f39”
},
{
“config_entry_id”: null,
“device_id”: null,
“disabled_by”: null,
“entity_id”: “binary_sensor.door_window_sensor_158d0001e46f39_2”,
“name”: null,
“platform”: “xiaomi_aqara”,
“unique_id”: “status_158d0001e46f39”
},

Please use 0.85.0. The correct unique_id format is status158d0001e46f39. This issue is fixed in 0.85.0.

1 Like

I’m already using the 0.85.0b1
Now i’m updating to the 0.85.0 official

Please update. I’m pretty sure I’ve fixed the issue.