BigThunderSR/homeassistant-addons-onstar2mqtt

Entities for Toggle

Closed this issue ยท 25 comments

I've installed the addon and configured mqtt. A LOT of entities were added, but they are all mostly sensors (ie. ambient air, fuel level, gas range, tire etc). I don't see a toggle for actually starting my car or locking/unlocking doors. Am I missing something? I've combed through the documentation, but I'm not seeing anything. I tried to sort this out myself before bothering anyone. Any help is appreciated.

This is in the documentation:

Example Script YAML

alias: Car - Start Vehicle
sequence:
  - service: mqtt.publish
    data:
      topic: homeassistant/YOUR_CAR_VIN/command
      payload: '{"command": "startVehicle"}'
mode: single
icon: 'mdi:car-electric'

You need to create HA scripts like the above for each command that you want to run.

An alternative (and in some ways simpler) method is to use my Node-RED module which can be installed in the HA Node-RED add-on:

https://github.com/BigThunderSR/node-red-contrib-onstar2

Thank you @BigThunderSR , I should have mentioned that I followed the documentation and tried that script. I can run the script and it looks like it goes through, but the vehicle never starts.

Thank you @BigThunderSR , I should have mentioned that I followed the documentation and tried that script. I can run the script and it looks like it goes through, but the vehicle never starts.

What's the response code you get back from the OnStar API when you run the command?

Thanks again for the response @BigThunderSR I initiated the script and then recorded the error (I should mention that when the addon connects to the car through mqtt initially, and the polling all seem to work as well as related sensors:

error: Error {"error":{"error":{"message":"Command Failure","request":{"body":"{}","contentType":"application/json; charset=UTF-8","headers":{},"method":0,"url":"https://api.gm.com/api/v1/account/vehicles/3GNAXNEG5RL113954/requests/46736709855"},"response":{"data":{"commandResponse":{"body":{"error":{"code":"ONS-216","description":"Unable to establish packet session to the vehicle"}},"completionTime":"2023-12-31T14:31:07.194Z","requestTime":"2023-12-31T14:30:07.097Z","status":"failure","type":"diagnostics","url":"https://api.gm.com/api/v1/account/vehicles/3GNAXNEG5RL113954/requests/46736709855"}},"headers":{"connection":"keep-alive","content-type":"application/json;charset=UTF-8","date":"Sun, 31 Dec 2023 14:31:10 GMT","request-context":"appId=cid-v1:a7e19842-5b19-4b47-a9cf-85cc6e87a746","transfer-encoding":"chunked"},"status":200,"statusText":"OK"},"stack":"Error: Command Failure\n at RequestService.<anonymous> (/app/node_modules/onstarjs/dist/index.cjs:558:35)\n at Generator.next (<anonymous>)\n at fulfilled (/app/node_modules/onstarjs/dist/index.cjs:26:58)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}},"timestamp":"2023-12-31 08:31:10"}

Thanks again for the response @BigThunderSR I initiated the script and then recorded the error (I should mention that when the addon connects to the car through mqtt initially, and the polling all seem to work as well as related sensors:

error: Error {"error":{"error":{"message":"Command Failure","request":{"body":"{}","contentType":"application/json; charset=UTF-8","headers":{},"method":0,"url":"https://api.gm.com/api/v1/account/vehicles/3GNAXNEG5RL113954/requests/46736709855"},"response":{"data":{"commandResponse":{"body":{"error":{"code":"ONS-216","description":"Unable to establish packet session to the vehicle"}},"completionTime":"2023-12-31T14:31:07.194Z","requestTime":"2023-12-31T14:30:07.097Z","status":"failure","type":"diagnostics","url":"https://api.gm.com/api/v1/account/vehicles/3GNAXNEG5RL113954/requests/46736709855"}},"headers":{"connection":"keep-alive","content-type":"application/json;charset=UTF-8","date":"Sun, 31 Dec 2023 14:31:10 GMT","request-context":"appId=cid-v1:a7e19842-5b19-4b47-a9cf-85cc6e87a746","transfer-encoding":"chunked"},"status":200,"statusText":"OK"},"stack":"Error: Command Failure\n at RequestService.<anonymous> (/app/node_modules/onstarjs/dist/index.cjs:558:35)\n at Generator.next (<anonymous>)\n at fulfilled (/app/node_modules/onstarjs/dist/index.cjs:26:58)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}},"timestamp":"2023-12-31 08:31:10"}

Please see bullet number 3 here:

https://github.com/BigThunderSR/homeassistant-addons-onstar2mqtt?tab=readme-ov-file#helpful-usage-notes

Thank you. I see that is indeed the error I'm getting; however, I've tried starting via mqtt immediately after shutting the car off, 15 minutes after shutting off and after it sat all night and all deliver the same error. Looking through the logs, it appears that it returns that error every time it "pings" my car at the set intervals. I completely stopped my HA vm and restarted and now I have a really weird phenomenon. In the onstar addon log, I'm no longer getting errors after I restarted HA, it's returning all the data again, and has beenfor about 2 hours without errors. However, the data isn't getting passed to mqtt for some reason. I tried deleting the instance in mqtt and restarted and it detected my vehicle and all the sensors, but they all say "unavailable". Any suggestions what I can do to pass the data to mqtt again? My mqtt credentials are all correct. Any help is greatly appreciated.

I'm currently facing an issue where my car is not accepting commands to start etc., but is sending back data whereas my wife's car is accepting commands and sending data without any issues and both cars are under my account. Unfortunately, such is the temperamental behavior of the OnStar API. These types of things sometimes go away after a few days or more, but there's no way to forcefully try to correct it. BTW, have you recently logged into the official GM app for your vehicle? They sometimes change EULA's and such that you need to accept through the official app which also prevents things working via the API as well.

Regarding the add-on itself, you can just shut down the add-on instead of shutting down the entire HA VM to try and get things to "soft reset" of sorts. What MQTT broker are you using?

Thank you very much for trying to help. I'll give it a few days to see what happens. I appreciate your help.

Thanks for the hint about shutting down the addon. I thought maybe killing everything and bringing it back up would help.

I'm using mosquitto broker. I've got about 30 devices connected through mqtt, this is the only one showing "unavailable". What's weird is it initially all showed up. I see that the addon is connected to onstar and publishing all the data and sending the messages....for some reason, mqtt just isn't receiving them.

Thank you very much for trying to help. I'll give it a few days to see what happens. I appreciate your help.

I edited my original response, so I think you missed the second part.

I just edited my post to respond as well, haha

I just edited my post to respond as well, haha

I think a graceful restart of the HA VM should bring everything back to a sane state. LMK if that works or not.

That didn't work. It's really odd. I may just remove the addon and try from the beginning again. I've attached a couple pictures showing that mqtt shows unavailable, but what's weird is if I go into the mqtt logs for my vehicle, it looks like it's receiving the data for all the sensors, the sensors just show unavailable. See pictures for reference.

*Pictures removed due to exposing personal information

That didn't work. It's really odd. I may just remove the addon and try from the beginning again. I've attached a couple pictures showing that mqtt shows unavailable, but what's weird is if I go into the mqtt logs for my vehicle, it looks like it's receiving the data for all the sensors, the sensors just show unavailable. See pictures for reference.

Your VIN is listed in the screenshots, so you may want to take them down and repost with the VIN blacked out.

Good point, I'll work on that. I actually scrolled down a bit to prevent my other more important data from being exposed, but forgot about the VIN.

What is the current value of "homeassistant/vin/available"?

Where would I find that value?

You need to query the value from your MQTT broker.

I'm looking in mosquitto, where would that value be within the broker? Sorry for the hassle by the way.

I'm looking in mosquitto, where would that value be within the broker? Sorry for the hassle by the way.

You would need to use something like this to view the topic contents:

https://mqtt-explorer.com/

Yeah, I have that installed and that's one of the ways I was able to verify that the addon is actually talking to mqtt. I just don't know where to find that particular value

I think I may have found it....I may have also found what may be my problem. In the "mqtt prefix" I originally had it set as "equinox" but then changed it to just "onstar" and republished and then restarted. Both instances are showing within explorer one shows available=true and the other shows available=false. The one that shows false is the one I originally had, but I can't help but think that maybe this is the issue? What are your thoughts?

So the topic you are looking for is literally "homeassistant/"your actual vehicle vin"/available". It should be visible just like any other topic you can see on your broker. If you cannot find it, that would also explain why all the car sensors are showing as unavailable because that topic needs to have a state of "true" for the car sensors to show up in HA.

Also just saw your latest post. I didn't realize you had changed the default topic prefix from "homeassistant". So yes, you need to reconcile all those changes and things should begin to work again.

Geez, that was it. I'm so sorry, you had to spend so much time helping a dip$hit. I'm back to trying to see if I can start it via the script again. Thanks for all your patience.

@BigThunderSR I was able to FINALLY get the car to start via the script. Thank you for your help. I really appreciate all the time you spent.

No worries and glad to hear everything is working now!