G-Two / subarulink

A python package for interacting with Subaru STARLINK remote vehicle services.
Apache License 2.0
86 stars 13 forks source link

Install Help #23

Closed ksuclark closed 3 years ago

ksuclark commented 3 years ago

I am wanting to help validate this but am struggling with how to get this installed into Home Assistant. I created a custom_components folder in config and then dropped in the "subaru" folder from components directory. Is there a place you could direct me to? My internet searches aren't turning up much unfortunately.

stboch commented 3 years ago

After you have placed the subaru folder in the custom_components then go to the integrations screen and click + look for subaru.

ksuclark commented 3 years ago

Got it, thanks! Had to clear my browser cache and then I was able to find and add it. Seems to work, with a few errors logged. Just let me know how you'd like to receive those.

Also, a suggestion to consider. Rather than polling for the lock status, add an option to assume it is unlocked by default so that I can easily lock (manually or through automation). I have a plugin for Buick through homebridge and this is how this one works. Once the lock command is sent, it reverts back to unlocked. Just a thought!

Thanks for making this. I do appreciate it.

G-Two commented 3 years ago

@ksuclark - Please paste in any errors you have in your logs, along with a few lines above the error for context. Be sure to sanitize any personal info from the log snippet. Which branch are you using, "subaru", or "subaru_initial_pr"? The former has more features (locks, services), but the latter is more refined after a few code reviews. I need to merge them so I can have the full feature set ready once this initial PR is complete (only one platform is allowed for an initial PR, so I chose sensors).

I just released 0.3.7 to PyPi which should fix the errors I'm aware of that come up when connecting/authorizing the first time. It'll also fix the SOA 403 error that happens after 24 hours. You can use this by updating manifest.json.

I did consider assuming unlocked for the door lock state and updating it after the first command is sent. The only problem is if someone unlocks with the key, the stored state becomes invalid. Since the Subaru API still doesn't support reporting lock state (it only returns "UNKNOWN"), there's no way to reliably keep the state in sync unless you only use Home Assistant to lock/unlock doors. So for now, this module (and Home Assistant) only support sending lock or unlock commands and don't attempt to maintain the state.

Thanks for previewing, please let me know if you have any other feedback.

G-Two commented 3 years ago

@ksuclark I just realized that the subaru branch was pretty old and didn't have things like services implemented. I recommend using the add_services branch, which I just now rebased off of the subaru_initial_pr branch and now includes all the code review changes (but also contains the additional features that I'm not permitted to include in an initial PR to the homeassistant core).

ksuclark commented 3 years ago

Excellent. I’ll upgrade everything tomorrow, retest, and report back. Thanks for this!

ksuclark commented 3 years ago

@G-Two I removed the prior version, restarted Home Assistant, and installed the one you linked above. The setup screen doesn't have any labels:

Screen Shot 2020-11-08 at 8 33 33 PM

I guessed it was username/password/PIN. From there the install aborted with the following errors (I am able to ping the URL below):

Unable to communicate with Subaru API: HTTP 500: <ClientResponse(https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json) [500 Server Error]> <CIMultiDictProxy('Server': 'Oracle-Traffic-Director/12.2.1.2.0', 'Date': 'Mon, 09 Nov 2020 02:29:08 GMT', 'Access-Control-Allow-Origin': '', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, DELETE', 'Access-Control-Allow-Headers': 'Accept, Content-Type', 'Content-Type': 'application/json;charset=UTF-8', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Via': '1.1 otd_prod_otd_prod-otd', 'Proxy-agent': 'Oracle-Traffic-Director/12.2.1.2.0', 'Transfer-Encoding': 'chunked')> 8:29:08 PM – subaru (ERROR) ('{"httpCode":500,"errorCode":"error","errorMessage":"java.lang.NullPointerException ' '- null"}') 8:29:08 PM – /usr/local/lib/python3.8/site-packages/subarulink/connection.py (ERROR) RequestInfo(url=URL('https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json'), method='POST', headers=<CIMultiDictProxy('Host': 'mobileapi.prod.subarucs.com', 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; Android SDK built for x86 Build/QSR1.191030.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.185 Mobile Safari/537.36', 'Origin': 'file://', 'X-Requested-With': 'com.subaru.telematics.app.remote', 'Accept-Language': 'en-US,en;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/*', 'Cookie': 'JSESSIONID=091CFCD3D9E912D93FA5B2DA0AFD6384; ORA_OTD_JROUTE=0t-ZDpuqZ8Kd9fOPUgWG3z-Lj7lLqZqf', 'Content-Length': '15', 'Content-Type': 'application/json')>, real_url=URL('https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json')) 8:29:08 PM – /usr/local/lib/python3.8/site-packages/subarulink/connection.py (ERROR) You are using a custom integration for subaru which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 8:27:37 PM – loader.py (WARNING)

G-Two commented 3 years ago

@ksuclark I just pushed 8a8d73e, which adds translations/en.json. This should fix the missing labels.

As for the HTTP 500 error, typically that is a result of attempting a Subaru API call that isn't supported by the target VIN. If this is happening during the config flow, then it is trying to test the PIN number supplied by firing a locate command. There are checks that should prevent this if your vehicle/subscription do not support it, but there may be an edge case that I overlooked. What year/model vehicle are you using, and what type of Subaru Starlink subscription do you have (Safety, Safety/Security, or None)?

ksuclark commented 3 years ago

@G-Two - Just tried again. The labels now show up...Woot! But I am still getting this error once I enter my details:

image

I verified they are correct by logging into MySubaru and testing an action. It is a 2020 Outback with the STARLINK® Safety & Security Plus plan.

ksuclark commented 3 years ago

@G-Two - Here's the log file info again (though I think it's the same)...

Unable to communicate with Subaru API: HTTP 500: <ClientResponse(https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json) [500 Server Error]> <CIMultiDictProxy('Server': 'Oracle-Traffic-Director/12.2.1.2.0', 'Date': 'Wed, 11 Nov 2020 22:24:21 GMT', 'Access-Control-Allow-Origin': '', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, DELETE', 'Access-Control-Allow-Headers': 'Accept, Content-Type', 'Content-Type': 'application/json;charset=UTF-8', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Via': '1.1 otd_prod_otd_prod-otd', 'Proxy-agent': 'Oracle-Traffic-Director/12.2.1.2.0', 'Transfer-Encoding': 'chunked')> 4:24:22 PM – Subaru (ERROR) ('{"httpCode":500,"errorCode":"error","errorMessage":"java.lang.NullPointerException ' '- null"}') 4:24:22 PM – /usr/local/lib/python3.8/site-packages/subarulink/connection.py (ERROR) RequestInfo(url=URL('https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json'), method='POST', headers=<CIMultiDictProxy('Host': 'mobileapi.prod.subarucs.com', 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; Android SDK built for x86 Build/QSR1.191030.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.185 Mobile Safari/537.36', 'Origin': 'file://', 'X-Requested-With': 'com.subaru.telematics.app.remote', 'Accept-Language': 'en-US,en;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/*', 'Cookie': 'JSESSIONID=ABD0756061401E67ABE612C757DCF9C4; ORA_OTD_JROUTE=0t-ZDpuqZ8Kd9fOPUgWG3z-Lj7lLqZqf', 'Content-Length': '15', 'Content-Type': 'application/json')>, real_url=URL('https://mobileapi.prod.subarucs.com/g2v17/service/g2/vehicleStatus/execute.json')) 4:24:22 PM – /usr/local/lib/python3.8/site-packages/subarulink/connection.py (ERROR) You are using a custom integration for subaru which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 4:21:01 PM – loader.py (WARNING)

ksuclark commented 3 years ago

@G-Two - Sorry for so many comments...For grins I tried again and it worked the second time through.

G-Two commented 3 years ago

@ksuclark no problem, let me know if you run into any other issues. Please give the services a try to make sure things like remote start/stop, lights, horn, etc work for your vehicle. I plan to add binary sensors (e.g. ignition state, door open, etc.) and vehicle location soon, so keep an eye out for new revisions in my homeassistant repo the new repo I setup to continue development while the initial PR is in review..

G-Two commented 3 years ago

HTTP 500 error during HA config UI setup appears to have been fixed with 0.3.9