G-Two / homeassistant-subaru

Subaru STARLINK custom component for Home Assistant.
Apache License 2.0
54 stars 6 forks source link

Error: Platform subaru does not generate unique IDs. #124

Closed tweas closed 3 weeks ago

tweas commented 4 weeks ago

Just for background: Running in docker on pi4, I had tried to pull the latest HA core version, 2024.6. After pulling, stopping and restarting the HA instance, something blew up. Kept getting the error "connection refused." Although I could log in, it kept "losing connection" and would never fully load.

Managed to revert to 2024.5.5 and everything magically worked EXCEPT the My Subaru instance. So, I redownloaded the latest update folder, copied it over to the custom components, and it too started working. Using "_sudo cp -r /home/pi/Downloads/homeassistant-subaru-main/custom_components/subaru /home/pi/HomeAssistant/customcomponents" to copy the extracted zip folder

The hitch is I get the below error in the logs whenever I reboot. The "{Redacted}" parts are long strings that are all identical. Note: I have two vehicles in the app. The Outback is the only one generating the errors. The Crosstrek has no errors.

So, everything appears to be working. But wondering if I need to do something about the errors below.

_Logger: homeassistant.components.binary_sensor Source: helpers/entity_platform.py:744 integration: Binary sensor (documentation, issues) First occurred: 7:20:32 PM (7 occurrences) Last logged: 7:20:32 PM

Platform subaru does not generate unique IDs. ID {Redacted}_DOOR_ENGINE_HOOD_POSITION already exists - ignoring binary_sensor.2022_outback_touring_xt_hood Platform subaru does not generate unique IDs. ID {Redacted}_DOOR_FRONT_LEFT_POSITION already exists - ignoring binary_sensor.2022_outback_touring_xt_front_left_door Platform subaru does not generate unique IDs. ID {Redacted}_DOOR_FRONT_RIGHT_POSITION already exists - ignoring binary_sensor.2022_outback_touring_xt_front_right_door Platform subaru does not generate unique IDs. ID {Redacted}_DOOR_REAR_LEFT_POSITION already exists - ignoring binary_sensor.2022_outback_touring_xt_rear_left_door Platform subaru does not generate unique IDs. ID {Redacted}_DOOR_REAR_RIGHT_POSITION already exists - ignoring binary_sensor.2022_outback_touring_xt_rear_rightdoor

G-Two commented 4 weeks ago

Are the redacted strings the VIN for your Outback? Is it the correct VIN, or is it erroneously using your Crosstrek's VIN?

Please attach your device diagnostics output for both vehicles.

image

tweas commented 4 weeks ago

It is the VIN. But, it is the correct VIN for the Outback. subaru-fb6d9ee389174cdec9165d30101e6af4-2022 Crosstrek Limited-66cf7e2ff241b4ecebe5a75400824a50.json subaru-fb6d9ee389174cdec9165d30101e6af4-2022 Outback Touring XT-0cf66a3fbe4c6fabd76208accf3fd641.json

G-Two commented 4 weeks ago

Thanks. And just to confirm, everything is functioning correctly?

tweas commented 4 weeks ago

Appears to be. I would have to go start the car manually to do anymore retests. It doesn't like so many commands without actually starting it with the key. but, I am able to locate, lock doors, etc. Pressures, odometer, and door sensors are reading correctly.

Not sure what the issue was trying to go to the latest stable HA instance was. But, wondering if the two issues might be related.

Staying on 2024.5.5 (HA Core) until I can figure out what broke on the update. Also, the subaru app is reporting ver 7.15 RC1. Is that correct?

tweas commented 3 weeks ago

Just popping back on to add: I had reverted to 2024.5.5 due to the startup loop issue I was having. There were issues posted in the HA Core Github around HACS causing a block on startup. After reading that the issue had been addressed, I backed everything up, and then updated to 2024.6.1.

This did allow me to run the latest stable version of core again. However, I am still getting the same unique ID issue. Was hoping the update might resolve the issue. But, it did not.

G-Two commented 3 weeks ago

Thanks. I'll try to figure out what's causing the error.

tweas commented 3 weeks ago

Everything IS still working. I actually tested all the functions over the weekend and all of it works. Just the odd error message. Is it possible that something got duplicated when the HA core was acting up? Any way to tell in the config files?

G-Two commented 3 weeks ago

Maybe there are some old orphaned entities? If you view all your subaru entities, are there any duplicates or broken ones? Your Outback should support reporting window open/close state. Is that working properly?

tweas commented 3 weeks ago

No duplicates showing in the graphical. However, if I look in the PY cache folder, I am seeing duplicates with the exception of a number identifier on the end. Everything is in there twice. Once each with a "-311" suffix on the file name before the .pyc file type and another with a "-312" suffix. All of the "-311" entries show a last modified date of 11/30/2023. All of the "-312" files show a modify date of 6/5/2024 -which is coincidentally, the date that I had issues. Also of note, the timestamp appears close to the time I I recovered from the crash. It Crashed at 17:37 (according to the dump) and I got it running on the old 2024.5.5 version a little over an hour and a half later after giving up on the stable 2024.6.0. Time stamp for the duplicate files is 18:55. **Edited to add, this is likely the time frame I would have downloaded the latest version of the Subaru Custom Components as the original instance was not working after reverting to 2024.5.5.

According to the .fault file, all of the issues appeared to be python issues (consistent with the issues listed on the 2024.6.0 core github page).

The windows do appear to report properly.

Screenshot 2024-06-11 165731
G-Two commented 3 weeks ago

I don't think any of the .pyc files would cause the error, since only the respective version would be used at runtime. If you've had the same HA instance over time, I'd expect to see .pyc files for both python 3.11 and 3.12.

Duplicates/orphaned entities that might cause the error would be found in config/.storage/core.entity_registry

Good to hear the windows status is working without error. I don't know why only a subset of subaru binary sensors are causing the duplicate entities error.

I can't find anything in the subaru integration that would cause this, as it does generate unique IDs formatted as VIN_<API_FIELD_NAME>. The HA core code that checks for collisions is here: https://github.com/home-assistant/core/blob/f02383e10db401a73927de5176ee436af8d533b6/homeassistant/helpers/entity_platform.py#L750

G-Two commented 3 weeks ago

How many entries are returned when you run:

$ grep DOOR_FRONT_LEFT_POSITION config/.storage/core.entity_registry

There should only be two (one for each car and they should have correct/different VINs in the unique id).

tweas commented 3 weeks ago

Two results Screenshot_20240611_184215_RVNC Viewer

G-Two commented 3 weeks ago

that looks fine. the config_entry_id is going to be the same for everything associated with the subaru integration entity (i.e. your MySubaru account configured in HA).

If you were to grep for that id, it should list all entities for the subaru integration.

G-Two commented 3 weeks ago

I did find a bug in my code that could possibly cause the issue for those with more than one vehicle. Please try 9a08a76

tweas commented 3 weeks ago

That did it Screenshot_20240612_085004_Home Assistant