Closed hoangtridung closed 2 years ago
It seems entity type should be included in the unique id. Although changing that, will cause all devices will be unmatched after the update and will get new entity ids.
I had this once previously, but I can't replicate it in my environment now. I believe I removed both conflicting entries from the entity_registry and then rebooted and it rediscovered correctly and added the devices back with unique IDs.
I removed all Google-Wifi entries from 2 registry file, re-installed integration. But it's unsuccessful.
Both switch and device_tracker which inherit GoogleWifiEntity
use device_id
for unique id, that's probably not right:
https://github.com/djtimca/hagooglewifi/blob/83ec434ae266fe0e2831157bd6172f75dff19faf/custom_components/googlewifi/__init__.py#L269
https://github.com/djtimca/hagooglewifi/blob/83ec434ae266fe0e2831157bd6172f75dff19faf/custom_components/googlewifi/__init__.py#L275-L278
Switch: https://github.com/djtimca/hagooglewifi/blob/83ec434ae266fe0e2831157bd6172f75dff19faf/custom_components/googlewifi/switch.py#L67 https://github.com/djtimca/hagooglewifi/blob/83ec434ae266fe0e2831157bd6172f75dff19faf/custom_components/googlewifi/switch.py#L80
Device tracker: https://github.com/djtimca/hagooglewifi/blob/83ec434ae266fe0e2831157bd6172f75dff19faf/custom_components/googlewifi/device_tracker.py#L43
I would have to go back and chase it out, but I'm pretty sure the unique id is by platform - HA actually differentiates between entity types when looking at the unique ID so you don't need to add that to the ID in the component.
If that wasn't the case then everyone with this integration would have the same issue and it is working correctly with the same unique ID in most installs including mine.
Yeah, I think you're right: https://github.com/home-assistant/core/blob/065e858a032f1315f702ccc19b7c23a8c5015025/homeassistant/helpers/entity_registry.py#L265
After looking at HA code the problem seems that device_tracker.huawei_nova_3e_huawei_android_device
already exists or that entity ID isn't available for use:
Not sure why though. Maybe there's some other integration which added entity with the same entity id?
I don't have any device_tracker.huawei_nova_3e_huawei_android_device before. GG Wifi have ~ 70 connected devices and them are disabled while this integration add to HA. Enabling any entity have the same error.
Does the same thing happen if you completely remove the integration and then re-install it?
Yes I remove the integration completely. Are there the place to check entity_id on HASS outside core.registry files ?
It is just on those files. If you remove the integration can you confirm the entities are removed from your core files?
Yes. It's move to section "deleted_devices" in file core.device_registry I manual delete those entry as follow:
}
],
"deleted_devices": []
}
}
In file core.entity_registry was clear.
Is the behaviour any different if you add the integration with devices enabled?
OOh, adding the integration as All Device Enabled --> Successful But all device_tracker entities always not_home. I's tried to disconnect and reconnect WIFI, but it's unsuccessful.
More info: Disable any entity and Re-enable it --> The error: Platform googlewifi does not generate unique IDs ... return
I am unable to replicate this behaviour in my environments. When I add the integration I get home and not_home correctly on device trackers and I can enable and disable entities with no issues.
If I add the integration with entities disabled I can enable them without issue.
What version of HA are you currently running? I tested with 2021.9.4 and 2021.10.0.dev0 and both worked correctly.
The new error from HASS log:
This error originated from a custom integration.
Logger: homeassistant.config_entries
Source: custom_components/googlewifi/__init__.py:61
Integration: Google WiFi Integration (documentation, issues)
First occurred: 5:57:30 PM (1 occurrences)
Last logged: 5:57:30 PM
Error setting up entry Google Wifi for googlewifi
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/googlewifi/__init__.py", line 61, in async_setup_entry
await api.connect()
File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 171, in connect
success = await self.get_api_token()
File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 148, in get_api_token
await self.get_access_token()
File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 140, in get_access_token
response = await self.post_api(url, headers, payload)
File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 37, in post_api
async with self._session.post(
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 619, in _request
break
File "/usr/local/lib/python3.9/site-packages/aiohttp/helpers.py", line 656, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
I'm experiencing the same as @hoangtridung.
I've just raised https://github.com/djtimca/googlewifi-api/pull/4 which will solve the timeout issue.
For future readers: After having the same issue, deleting the entry with the specific ID in core.device_registry and re-installing the add-on, the problem resolved itself for me.
I' installed packet v 0.1.28 on HA 2021.9.4 and have error:
Search string 7C49345E82411EAC9C4201489890ABDAC7FDE5315E27D47967FEFE9059BBC629 only exist in 2 file in .storage folder: --> 1 hit in core.device_registry file as:
--> 2 hit in core.entity_registry file as:
I guest 2 entity : switch and device_tracker are conflict by using the same unique_id": "7C49345E82411EAC9C4201489890ABDAC7FDE5315E27D47967FEFE9059BBC629". How to troubleshoot this problem ?
Thank for any advice !!!