michaelwoods/onstar2mqtt

Request Failed with status 400 - Bad Request

Closed this issue · 38 comments

Getting the following when starting the application:

info: Requesting vehicles
error: Main function error. {"error":{"message":"Request Failed with status 400 - Bad Request","request":{"

Are you seeing anything similar?

Hello, yes I am getting the same thing: error: Main function error. {"error":{"message":"Request Failed with status 400 - Bad Request","request":{"_contentLength":null,"_defaultKeepAlive":true,"_ended":true,"_events":

I accidentally realized it wasn't working (because I haven't finished my dashboard). I got in the logs today and confirmed that was the error. I can log into the native app fine (I thought maybe they were forcing a password reset). Nothing else has changed. It looks like it's still sending information back (which would indicate it's getting past authentication) but maybe they changed something in the API that's jumbling the response and that's why we're getting stuck?

Updating OnstarJS fixed the Bad Request error for me, but after rebuilding the docker container with the newer onstarJS version, it just exits after "info: Vehicle request status {"status":"success"}".

Same issue here. Following

This issue appears to be happening with the NPM version as well. It will get the success message, but will not publish anything to the MQTT topic.

Actually was an issue on my part. I have this working for anyone interested, but as stated above, it does require NPM. If you have not done NPM version before here is a step by step,

sudo wget https://www.github.com/michaelwoods/onstar2mqtt
cd onstart2mqtt
npm install
npm i onstarjs
npm run start

This way is passing information to my HomeAssistant MQTT. Now I personally was unsure of how to pass the variables so I did do the following.

cd src
sudo nano index.js
deviceId: process.env.ONSTAR_DEVICEID || 'uuidhere',
    vin: process.env.ONSTAR_VIN || 'vinhere',
    username: process.env.ONSTAR_USERNAME 'usernamehere',
    password: process.env.ONSTAR_PASSWORD 'password here',
    onStarPin: process.env.ONSTAR_PIN 'pinhere',

I also filled in the spots for the HomeAssistant portion. If anyone needs asistance, you can reach out to me.

Gibby commented

Anyone else having this issue can point to this docker image that has @BennyDaBee fixes in it
ghcr.io/gibby/onstar2mqtt:v1.4.2

@Gibby taking a look at your files, it does appear that it uses my Gas Vehicle Fork. Keep in mind that this will break for any EV.

Can confirm that using ghcr.io/gibby/onstar2mqtt:v1.4.2 fixed it for me; granted, I have a gas-powered Traverse.

Thanks @Gibby. Up and running again

Thanks @Gibby. Everything is working. Not sure if it's my imagination but I'm clocking severely improved response times (27-30 seconds). I don't recall this working that fast; I put it through its paces and couldn't trip it up at all.

@lymanbuttler I can make something using node, but not docker, but if @Gibby wants to set up the docker after I get the EV branch working, I can certainly get that going

@Gibby @BennyDaBee That would be amazing, thanks!

Any update on getting this resolved in the docker container for EVs?

Gibby commented

I seem to be getting the error again.

I started getting errors again sometime yesterday

With updated dependencies, it is still giving errors. I will be taking a look further.

Taking a deeper dive, it appears that the appToken needs to be updated in OnStarJS. I opened a request with that dev to update it.

@lymanbuttler I dont think there should be a difference in EV vs Gas. Michaels original onstar2mqtt was made for his EV i believe but it also worked with gas vehicles (like my silverado) without an issue (unless there is something going on like this 400 bad request error)

I sometimes get some weird 200/201s back with a non descriptive error and nothing gets published to mqtt. To fix it my truck has to be running/moving for awhile and then i have to restart the docker image for it to start getting diagnostics. Not sure if anyone else runs into that.

Thanks you @BennyDaBee and @Gibby for staying on top of this! This is one of my favorite lil add-ons for HA and I love bragging about it.

@phildh The main issue with Michaels is that while yes it does work with Gas, it doesn't do it well. It has some conflicts when it comes to converting Kilometers to Miles and Liters to Gallons.

As for the 200/201 Error, I do think its that the Silverado will only respond to API Diagnostic Requests for so long before it just stops, or the API has received to many requests since the last start. So yes, running the vehicles for a bit does fix it, but it should not be necessary to restart the docker container.

@phildh I've had this problem for at least a couple months now, despite frequent use of the car and multiple Docker restarts, so an OnstarJS problem seems pretty likely to be our culprit.

Error back for me with @Gibby docker as well

Just updating all of you today, the issue is still ongoing and I have not heard back from the OnStarJS dev. I did send him an email as well about this issue.

THIS IS IMPACTING ALL RELEASES OF ONSTAR2MQTT

Gibby commented

@BennyDaBee ty, I have opened a PR in my repo that has your latest main changes. Gibby#23

Once there is a fix from OnStarJS it will be a quick update and then able to test the docker image.

@Gibby I have made a new branch called docker-compatible, please use that one as my main has been converted to NPM focused using ENV variables

OnStarJS Dev did push a fix. Testing now.

Seems to be working. @Gibby, please make a new PR using my Docker-compatible branch

Gibby commented

@BennyDaBee docker is working.

For those wanting to point to my image, I recommend using one of these:
ghcr.io/gibby/onstar2mqtt:latest
ghcr.io/gibby/onstar2mqtt:v1
ghcr.io/gibby/onstar2mqtt:v1.4

Just fired up ghcr.io/gibby/onstar2mqtt:latest, and it's working great. Appreciate the fix; HA is happy again! (edit: 2022 Bolt EUV)

confirmed @Gibby's fork is working great for 2019 Bolt EV.

Confirmed @Gibby's latest fixed my truck. Thanks

Thanks for holding things down @Gibby! I've been MIA due to life events but I've merged a few PRs, updated to Node 18 and to the latest OnstarJS.

Please use the latest image or 1.5.0.

Am I doing something wrong, I pointed to @Gibby's since I am gas and I am still getting a "Request Failed with status 503 - Service Unavailable" Or did it break again in a week?

@BennyDaBee doesnt matter which i point to, all result in Request Failed with status 503 - Service Unavailable and the docker container rebooting on loop

@BennyDaBee I am an idiot and had spaces after the equals sorry for wasting your time