G-Two / homeassistant-subaru

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

Multiple Subaru accounts #30

Closed jd-daniels closed 2 years ago

jd-daniels commented 2 years ago

I have what seems to be an outlier use case. That is, I'm trying to use this integration twice. We have two starlink accounts, that have separate users/pass/pin. Due to how the integration is written, it's not possible with the current code.

My first attempt at a quicker workaround was to fork this repo and then just change the domain and any other overlapping components. This seemed to work at first, but then I saw inconsistent where either one or the other account could perform remote services.

I think the ultimate issue can be traced to the aiohttp library creating an auth session against the API endpoint. This session seems to overlap between multiple integrations within the home assistant context. Such that if you add a new integration, no matter the domain, the session will be overwritten with the newer auth session.

I might be on my own here, but figured it was worth reaching out in case there were any ideas. If you don't think this issue is relevant to the project, feel free to close, and I'll try to figure something out.

jd-daniels commented 2 years ago

In case anyone wants to know. My workaround fork with a different domain does work once you replace the call to the aiohttp library that retrieves the same session with one that starts a new session, so that it doesn't overwrite it. Commit solving that problem

Otherwise, if the maintainers don't want this in scope, feel to close.

G-Two commented 2 years ago

@jd-daniels Thanks for figuring out the multi-account workaround. I'll test it out and if everything works on my end, I'll include it with v0.6.0rc0 (which adds climate presets support!), hopefully to be released tonight.

stboch commented 2 years ago

btw in addition at least in the US you can share access to cars in the app so cars can stay on multiple users but be accessible to multiple people. or in the case of me 1 user used by home-assistant.

jd-daniels commented 2 years ago

btw in addition at least in the US you can share access to cars in the app so cars can stay on multiple users but be accessible to multiple people. or in the case of me 1 user used by home-assistant.

Just a note on this. I tried to consolidate by doing this so I wouldn't have to maintain a separate repo. The data all came in (single integration but had 2 cars), but when I tried to execute remote commands on the 2nd car shared to the account, it failed because of invalid PIN. I tried to change the PIN to match so both were the same, this just gave invalid credentials. So it's still not quite a solution here.

I went back to merging upstream back into my secondary repo for the second account. This still works in v6.0

Cheers.