michaelwoods / onstar2mqtt Goto Github PK
View Code? Open in Web Editor NEWOnStarJS wrapper for MQTT
License: MIT License
OnStarJS wrapper for MQTT
License: MIT License
First of all, thank you for this wrapper.
Here are my results from MQTT Explorer.
Notice that "fuel_amount" and "fuel_level_in_gal" have the same result.
Topic = homeassistant/sensor/1GNSCAKC3Hxxxxxxxx/fuel_tank_info/state
{
"fuel_amount": 23.04,
"fuel_capacity": 99.75,
"fuel_level": 23.1,
"fuel_level_in_gal": 23.04
}
Topic = homeassistant/sensor/1GNSCAKC3Hxxxxxxxx/fuel_level_in_gal/config
{
"name": "Fuel Level In Gal",
"device": {
"identifiers": [
"1GNSCAKC3Hxxxxxxxx"
],
"manufacturer": "Chevrolet",
"model": "2017",
"name": "2017 Chevrolet Tahoe"
},
"availability_topic": "homeassistant/GNSCAKC3Hxxxxxxxx/available",
"payload_available": "true",
"payload_not_available": "false",
"state_topic": "homeassistant/sensor/GNSCAKC3Hxxxxxxxx/fuel_tank_info/state",
"value_template": "{{ value_json.fuel_level_in_gal }}",
"unique_id": "GNSCAKC3Hxxxxxxxx-fuel-level-in-gal",
"unit_of_measurement": "L"
}
I believe "unit_of_measurement": should be "G"
Thank You,
Jason
Not sure what the issue could be, but it started happening Saturday night/Sunday morning:
[email protected] start /app
node src/index.js
info: OnStar Config {"onstarConfig":{"deviceId":"OMMITED","vin":"OMMITED","username":"OMMITED","password":"OMMITED","onStarPin":"OMMITED","checkRequestStatus":true,"refreshInterval":1800000,"allowCommands":true}}
info: MQTT Config {"mqttConfig":{"host":"OMMITED","username":"OMMITED","password":"OMMITED","port":1883,"tls":false,"prefix":"OMMITED"}}
info: Requesting vehicles
info: Vehicle request status {"status":"success"}
info: Connecting to MQTT {"url":"mqtt://OMITTED:1883","config":{"username":"OMMITED","will":{"topic":"OMMITED/available","payload":"false","retain":true}}}
info: Connected to MQTT
info: Subscribed to command topic {"topic":"OMMITED/OMMITED/command"}
info: Requesting diagnostics
error: Error {"error":{"response":{"status":202,"statusText":"Accepted","headers":{"gccx-transactionid":"0000017a292f0f15-1184de","content-type":"application/json;charset=UTF-8","content-length":"180","date":"Mon, 21 Jun 2021 15:25:57 GMT","server":"Layer7-API-Gateway"},"config":{"url":"https://api.gm.com/api/v1/account/vehicles/OMMITED/commands/connect","method":"post","data":"{}","headers":{"Accept":"application/json","Content-Type":"application/json; charset=UTF-8","Accept-Language":"en-US","Host":"api.gm.com","Connection":"keep-alive","Accept-Encoding":"br, gzip, deflate","User-Agent":"Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)","Authorization":"Bearer OMMITED","Content-Length":2},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1},"request":{"_events":{},"_eventsCount":7,"outputData":[],"outputSize":0,"writable":true,"_last":true,"chunkedEncoding":false,"shouldKeepAlive":true,"_defaultKeepAlive":true,"useChunkedEncodingByDefault":true,"sendDate":false,"_removedConnection":false,"_removedContLen":false,"_removedTE":false,"_contentLength":null,"_hasBody":true,"_trailer":"","finished":true,"_headerSent":true,"socket":{"_tlsOptions":{"pipe":false,"secureContext":{"context":null,"singleUse":true},"isServer":false,"requestCert":true,"rejectUnauthorized":true,"session":
Logs are not giving much information on what issue could be. Its odd, when I'm restarting the docker image the sensors in HA go to unavailable, but once docker image is up it reflects old values before issue started.
We currently only read data from the OnStar API. We should subscribe to topics so that Home Assistant can send commands to the service and trigger horn, lights, remote start, etc.
It'd be nice for people looking at this to be able to quickly know how frequently this data automatically refreshes without needing to look through the code.
I was wondering why this was not working anymore for some time and checked my syno docker and the service keeps failing to start. logs show an error 400 after the command "Requesting vehicles" starting with
error: Main function error. {"error":{"message":"Request Failed with status 400 - Bad Request","request":{" etc...
Hello,
I notice everything is currently publish in HA format. I don't use HA, I use openhab. It would be great if a param could be set to change the mqtt path to something else then homeassistant. Also, maybe another one for the name instead of using the serial number?
Thank you!
Since earlier this week, the following commands are now returning a response of "status":403,"statusText":"Forbidden":
The following still work:
Example:
error: Command error {"command":"startVehicle","err":{"message":"Request Failed with status 403 - Forbidden"
Sensors (eg, tire pressure) are converting into PSI, however the recommendation attribute is still in kPa.
I have been trying to convert kilometers to miles as well as kpa to psi.
how can this be archived?
I found a bug from your last update to index.js in commit ad3f292 which prevents the location data from being published to MQTT. I was able to fix the issue by changing the following code from (Note items showing **xx**
):
const commandFn = cmd.bind(commands);
logger.info('Command sent', {command});
commandFn(options || {})
.then(data => {
// TODO refactor the response handling for commands
logger.info('Command completed', {command});
**data** = _.get(data, 'response.data');
if (**data**) {
logger.info('Command response data', {**data**});
const location = _.get(data, 'response.data.commandResponse.body.location');
if (location) {
const topic = mqttHA.getStateTopic({name: command});
// TODO create device_tracker entity. MQTT device tracker doesn't support lat/lon and mqtt_json
// doesn't have discovery
client.publish(topic,
JSON.stringify({latitude: location.lat, longitude: location.long}), {retain: true})
.then(() => logger.info('Published location to topic.', {topic}));
}
}
})
To:
const commandFn = cmd.bind(commands);
logger.info('Command sent', { command });
commandFn(options || {})
.then(data => {
// TODO refactor the response handling for commands
logger.info('Command completed', { command });
**const responseData** = _.get(data, 'response.data');
if (**responseData**) {
logger.info('Command response data', { **responseData** });
const location = _.get(data, 'response.data.commandResponse.body.location');
if (location) {
const topic = mqttHA.getStateTopic({ name: command });
// TODO create device_tracker entity. MQTT device tracker doesn't support lat/lon and mqtt_json
// doesn't have discovery
client.publish(topic,
JSON.stringify({ latitude: location.lat, longitude: location.long }), { retain: true })
.then(() => logger.info('Published location to topic.', { topic }));
}
}
})
Hello,
It would be nice to have a status chjannel where the last status is posted. It could be the reply of last command (like unlock/lock), the status of the last refresh and maybe happened the date time and what was last requested. This way at least, we could trap when something doesn't go well easier.
Thank you!
Is there any way to determine if the car is "on" or if the car is locked before sending a command to turn it on or lock it?
This is not so much of an issue as a feature request. Perhaps it’s already there but I don’t know how to use it… in the installation under Node.js, it says to just define the environment vars and run but the code isn’t “looking” for a .env file nor any other file such as the onstar2mqtt.env that’s mentioned above. I’m sure it’s fine in Docker but I’m running it in Node as a windows service.
To make it work, I simply added the dotenv requirement to the top of index.js and added it to dependencies.
Index.js
require('dotenv').config();
package.json
"dotenv": "^16.0.3",
This works but I must do it each time I pull a new version from your main branch or find a fork that already has it but isn’t as up to date as yours… perhaps I’m just not defining the env vars correctly :) but I did notice the code is natively setup for .env / dotenv so I made that assumption and it works
Home Assistant is able to convert from C to F, but the other units do not seem to convert even if they contain a device_class
and unit_of_measurement
.
Figure out why that is, or add a flag to convert prior to sending to MQTT.
I am running onstar2mqtt on a synology NAS via the docker plugin.
All the environement variables are filled in , onstar2mqtt grabs everything and pushes it to MQTT. ONSTAR_DEVICEID is also in the environement variables.
I have 2 instances of onstar2mqtt running, each for a different car, but same onstar account. (different VIN, different generated devideID)
I can read everything in Home Assistant but the entities names are doubled (i.e. ev_plug_state and ev_plug_state_2)
However :
Having an issue where it is not converting the Kilometers per liter to Miles per gallon
getLocation not working for about a week. Response: Request Failed with status 401 - Unauthorized
Can we get #240 merged. Maybe that will fix.
I've tried the "gibby" fork and same thing happens there. I also tried changing the device ID, but that didn't do anything. I've confirmed that the app works and the pin/password is correct.
<tr><td>2023-01-29T16:33:56.083060540Z</td><td>stderr</td><td>error: Main function error. {"error":{"message":"Request Failed with status 400 - Bad Request","request":{"_contentLength":null,"_defaultKeepAlive":true,"_ended":true,"_events":{},"_eventsCount":7,"_hasBody":true,"_header":"POST /api/v1/oauth/token HTTP/1.1\r\nAccept: application/json\r\nContent-Type: text/plain\r\nAccept-Language: en\r\nHost: api.gm.com\r\nConnection: keep-alive\r\nAccept-Encoding: br, gzip, deflate\r\nUser-Agent: Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)\r\nContent-Length: 455\r\n\r\n","_headerSent":true,"_keepAliveTimeout":0,"_last":true,"_redirectable":{"_currentRequest":"[Circular]","_currentUrl":"https://api.gm.com/api/v1/oauth/token","_ended":true,"_ending":true,"_events":{},"_eventsCount":2,"_options":{"agents":{},"headers":{"Accept":"application/json","Accept-Encoding":"br, gzip, deflate","Accept-Language":"en","Connection":"keep-alive","Content-Length":455,"Content-Type":"text/plain","Host":"api.gm.com","User-Agent":"Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)"},"hostname":"api.gm.com","maxBodyLength":10485760,"maxRedirects":21,"method":"POST","nativeProtocols":{"http:":{"METHODS":["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PRI","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"],"STATUS_CODES":{"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I'm a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Unordered Collection","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"},"globalAgent":{"_events":{},"_eventsCount":2,"defaultPort":80,"freeSockets":{},"keepAlive":false,"keepAliveMsecs":1000,"maxFreeSockets":256,"maxSockets":null,"maxTotalSockets":null,"options":{"path":null},"protocol":"http:","requests":{},"scheduling":"fifo","sockets":{},"totalSocketCount":0},"maxHeaderSize":8192},"https:":{"globalAgent":{"_events":{},"_eventsCount":2,"_sessionCache":{"list":["api.gm.com:443::::::::::::::::::"],"map":{"api.gm.com:443::::::::::::::::::":{"data":
Pulled a new image yesterday and restarted my docker image and I'm no longer getting my statistics. It was working with the docker image i was running, but I'm not sure what its version was. I usually don't pull your latest/weekly release when I'm not having issues.
`> [email protected] start /app
node src/index.js
info: OnStar Config {"onstarConfig":{"deviceId":"c25df90e-329e-48af-ba60-78940dce85d2","vin":"VIN-OMMITED","username":"EMAIL-OMMITED","password":"PASSWORD-OMMITED","onStarPin":"PIN-OMMITED","checkRequestStatus":true,"refreshInterval":1800000,"allowCommands":true}}
info: MQTT Config {"mqttConfig":{"host":"IP-OMMITED","username":"homeassistant","password":"MQTT-PASS-OMMITED","port":1883,"tls":false,"prefix":"homeassistant"}}
info: Requesting vehicles
info: Vehicle request status {"status":"success"}
info: Connecting to MQTT {"url":"mqtt://IP-OMMITED:1883","config":{"username":"homeassistant","will":{"topic":"homeassistant/VIN-OMMITED/available","payload":"false","retain":true}}}
info: Connected to MQTT
info: Subscribed to command topic {"topic":"homeassistant/VIN-OMMITED/command"}
info: Requesting diagnostics
error: Error {"error":{"response":{"status":202,"statusText":"Accepted","headers":{"gccx-transactionid":"0000017c59cd6cea-105530e","content-type":"application/json;charset=UTF-8","content-length":"179","date":"Tue, 12 Oct 2021 13:19:15 GMT","server":"Layer7-API-Gateway"},"config":{"url":"https://api.gm.com/api/v1/account/vehicles/VIN-OMMITED/commands/connect","method":"post","data":"{}","headers":{"Accept":"application/json","Content-Type":"application/json; charset=UTF-8","Accept-Language":"en-US","Host":"api.gm.com","Connection":"keep-alive","Accept-Encoding":"br, gzip, deflate","User-Agent":"Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)","Authorization":"Bearer d903aa90-e392-4152-bd9e-b9a4335760e1","Content-Length":2},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1},"request":{"_events":{},"_eventsCount":7,"outputData":[],"outputSize":0,"writable":true,"_last":true,"chunkedEncoding":false,"shouldKeepAlive":true,"_defaultKeepAlive":true,"useChunkedEncodingByDefault":true,"sendDate":false,"_removedConnection":false,"_removedContLen":false,"_removedTE":false,"_contentLength":null,"_hasBody":true,"_trailer":"","finished":true,"_headerSent":true,"socket":{"_tlsOptions":{"pipe":false,"secureContext":{"context":null,"singleUse":true},"isServer":false,"requestCert":true,"rejectUnauthorized":true,"session"
`
Are you having this issue with your latest docker build? Any advice on what I could try? I verified MQTT is working as expected. Any help would be greatly appreciated as I use this integration daily.
Is there any info on how often you can request info? I've been getting errors ending with "status":429,"statusText":"Too Many Requests". I have it on the default 30min refresh time.
Really excited to add this to my home assistant. Is there a way to get this working with multiple Bolt EVs? I'm currently trying to run it with 2 separate docker instances each pointing to a different VIN, but when they publish to my HA MQTT, I think they're all going into the same sensor (sensor.ev_*). Is there a way that I can influence the auto discovery capability in HA to have 2 sets of these sensors?
Thanks for your work on this
Getting this error on startup. I know my login is good.
info: Requesting vehicles
error: Main function error. {"error":{"message":"Request Failed with status 500 - Internal Server Error","request":{"_contentLength":null,"_defaultKeepAlive":true,"_ended":true,"_events":{},"_eventsCount":7,"_hasBody":true,"_header":"POST /api/v1/oauth/token HTTP/1.1\r\nAccept: application/json\r\nContent-Type: text/plain\r\nAccept-Language: en\r\nHost: api.gm.com\r\nConnection: keep-alive\r\nAccept-Encoding: br, gzip, deflate\r\nUser-Agent: Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)\r\nContent-Length: 420\r\n\r\n","_headerSent":true,"_keepAliveTimeout":0,"_last":true,"_redirectable":{"_currentRequest":"[Circular]","_currentUrl":"https://api.gm.com/api/v1/oauth/token","_ended":true,"_ending":true,"_events":{},"_eventsCount":2,"_options":{"agents":{},"headers":{"Accept":"application/json","Accept-Encoding":"br, gzip, deflate","Accept-Language":"en","Connection":"keep-alive","Content-Length":420,"Content-Type":"text/plain","Host":"api.gm.com","User-Agent":"Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)"},"hostname":"api.gm.com","maxBodyLength":10485760,"maxRedirects":21,"method":"POST","nativeProtocols":{"http:":{"METHODS":["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PRI","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"],"STATUS_CODES":{"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I'm a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Unordered Collection","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"},"globalAgent":{"_events":{},"_eventsCount":2,"defaultPort":80,"freeSockets":{},"keepAlive":false,"keepAliveMsecs":1000,"maxFreeSockets":256,"maxSockets":null,"maxTotalSockets":null,"options":{"path":null},"protocol":"http:","requests":{},"scheduling":"fifo","sockets":{},"totalSocketCount":0},"maxHeaderSize":8192},"https:":{"globalAgent":{"_events":{},"_eventsCount":2,"_sessionCache":{"list":["api.gm.com:443::::::::::::::::::"]
The config option, json_attributes_template
, is not working. It would be nice to set the recommended pressure of a tire as an attribute on the tire pressure sensors.
Add something to add a little more functionality than console.log
.
Thanks for adding in location support.
Could we get a confirmation on the command sent to OnStar posted into MQTT somewhere.
Example: homeassistant/VIN/last_command_sent
and homeassistant/VIN/last_command_status
error: Command error {"command":"startVehicle","err":{"request":{"authRequired":true,"body":"{}"
It appears as though the command is being sent correctly, and I can retrieve status for odometer, tpms etc, but cannot send commands. 2021 Chevy BOLT EV, Canadian OnSTAR account.
Hi,
I am trying to run the docker container. Here is the docker logs I get before the container crashes/stops.
> [email protected] start /app
> node src/index.js
info: OnStar Config {"onstarConfig":{"deviceId":"OMIT","username":"OMIT","password":"OMIT","onStarPin":"OMIT","checkRequestStatus":true,"refreshInterval":1800000,"allowCommands":true}}
info: MQTT Config {"mqttConfig":{"host":"10.0.0.8","username":"","password":"","port":1883,"tls":false,"prefix":"homeassistant/onstar"}}
error: Main function error. {"error":{}}
***this repeats twice before the containers crashes/stops
Is there a debug flag or something else to help debug?
Could it be that my MQTT server does not require a user/pass?
Any help would be appreciated, thanks.
As witnessed in #103 , it appears users (Maybe only with the 5-year-free "EV Mobile Command" package?) are limited to pulling diagnostic information 8 times before powering their vehicle on (and resetting the counter).
Requests for diagnostics after 8 attempts will begin returning with "error: Error" until the vehicle is powered on again.
With the above in mind, the threshold should likely be a default of 2 hours between checks, and adjustable via environment variables to the container.
Great dev, I imported this in my HA instance but struggled to put in place the dashboard as it was presented in your screenshot, after many tries and fidgeting with the scripts using the examples provided in HA-MQTT.md
I gathered that
payload: '{"command": "cancelStartVehicle"} - cancels the start of the vehicule previously started with '{"command": "startVehicle"}'
payload: '{"command": "lockDoors"}' locks the doors
payload: '{"command": "UnlockDoors"}' unlocks the doors
I failed to find a place where all the commands were listed... this would be a nice thing to have in addition to the files in git.
RIght now, you can only set a refresh interval at launch. Normally, 30min is fine. Every once in a while, it'd be nice to force a refresh when I choose to.
Recently, when trying to start my vehicle on these cold michigan mornings, I am getting a 403 - Forbidden Errors.
Any chance someone could do a step by step guide on how to get this running on a docker hosted on proxmox?
When the OnStar API inevitably fails, provide a new /status
topic or binary_sensor
so that we can indicate availability.
Thanks again for the great work on this!
Everything works for me except for the Alert function. It fails on both my cars. I get the following error whenever I try to run the alert command.
Command Sent:
2022-10-18 20:50:07 info: Command sent {"command":"alert"}
Error from command:
2022-10-18 20:50:07 error: Command error {"command":"alert","err":{"message":"Request Failed with status 400 - Bad Request","request":{"_closed":true,"_contentLength": 74,"_defaultKeepAlive":true,"_ended":true,"_events":{},"_eventsCount":7,"_hasBody":true,"_header":"POST..........................|snip| }
All working good when vehicle is running. However, I see this when the vehicle is off.
info: Publishing message {"payload":{"availability_topic":"homeassistant/xxx/available","device":{"identifiers":["xxx"],"manufacturer":"GMC","model":"2021","name":"2021 GMC Yukon Denali XL"},"name":"Gas Range","payload_available":"true","payload_not_available":"false","state_topic":"homeassistant/sensor/xxx/vehicle_range/state","unit_of_measurement":"km","value_template":"{{ value_json.gas_range }}"},"topic":"homeassistant/sensor/xxx/gas_range/config"}
info: Publishing message {"payload":{"availability_topic":"homeassistant/xxx/available","device":{"identifiers":["xxx"],"manufacturer":"GMC","model":"2021","name":"2021 GMC Yukon Denali XL"},"name":"Gas Range Mi","payload_available":"true","payload_not_available":"false","state_topic":"homeassistant/sensor/xxx/vehicle_range/state","unit_of_measurement":"mi","value_template":"{{ value_json.gas_range_mi }}"},"topic":"homeassistant/sensor/xxx/gas_range_mi/config"}
info: Publishing message {"state":{"gas_range":"XXX","gas_range_mi":null},"topic":"homeassistant/sensor/xxx/vehicle_range/state"}
I am making calls for 2 different VINs, one works well, the other returns errors. Same configuration exactly except that the VIN is different. They are both returning values that can be read in HA but #1 ends its script with 'info: Updates complete, sleeping.' where #2 ends its script with an insanely long suite of what seems to be one long error message starting with : 'error: Error {"error":{"request":{"authRequired":true,"body":"{}","checkRequestStatus":true,"contentType":"application/json; charset=UTF-8","headers":{},"method.......'
Only difference I can see between the 2 VIN : one is for a car coming from the US (#1), one is for a car coming from Canada (#2).
Manually running the "diagnostics" command succeeds as seen in the onstar2mqtt log, but the data is not actually refreshed by onstar2mqtt. The only way to force a refresh successfully is to restart onstar2mqtt.
This seems to be similar to what is mentioned in #225 (comment) although I am not seeing any errors as mentioned in that thread in the case where the command actually succeeds.
Hello,
Installed your image a few days ago and set it up in a docker image. Been running flawlessly on my 2022 GMC Acadia. I am able to start, lock/unlock doors, show tire pressures, etc..
That is until today. I tried to start my vehicle using my Home Assistant dashboard script (like always) and noticed a few minutes later that it didn't start. I am seeing the following message after running the docker container (I have removed my personal details and VIN #):
info: OnStar Config {"onstarConfig":{"allowCommands":true,"checkRequestStatus":true,"deviceId":"v4 UUID","onStarPin":"XXXX","password":"XXXXX","refreshInterval":1800000,"username":"user email","vin":"VIN NUMBER"}}
info: MQTT Config {"mqttConfig":{"host":"192.168.5.4","namePrefix":"","password":"mqtt_password","port":1883,"prefix":"homeassistant","tls":false,"username":"mqtt_user"}}
info: Requesting vehicles
info: Vehicle request status {"status":"success"}
info: Connecting to MQTT {"config":{"username":"mqtt_user","will":{"payload":"false","retain":true,"topic":"homeassistant/VIN NUMBER/available"}},"url":"mqtt://192.168.5.4:1883"}
info: Connected to MQTT
info: Subscribed to command topic {"topic":"homeassistant/VIN NUMBER/command"}
info: Requesting diagnostics
error: Error {"error":{"message":"Request Failed with status 500 - Internal Server Error","request":{"_closed":true,"_contentLength":383,"_defaultKeepAlive":true,"_ended":true,"_events":{},"_eventsCount":7,"_hasBody":true,"_header":"POST /api/v1/oauth/token/upgrade HTTP/1.1\r\nAccept: application/json\r\nContent-Type: text/plain\r\nAccept-Language: en-US\r\nHost: api.gm.com\r\nConnection: keep-alive\r\nAccept-Encoding: br, gzip, deflate\r\nUser-Agent: Mozilla/5.0 (Linux; U; Android 9; en-US; Google Pixel 2 Build/PI)\r\nAuthorization: Bearer
The last line is way longer, that is just a portion of it. I don;t see any other logs to look at. I completely re-created the docker container image and get the same results.
I'm at a loss. Any ideas to try?
Thanks,
Scott
Hello,
For the last days, nothing get updated from the onstar2mqtt docker.
> [email protected] start
> node src/index.js
info: OnStar Config {"onstarConfig":{"allowCommands":true,"checkRequestStatus":true,"deviceId":"###","onStarPin":"###","password":"###","refreshInterval":1800000,"requestPollingIntervalSeconds":6,"requestPollingTimeoutSeconds":60,"username":"###","vin":"###"}}
info: MQTT Config {"mqttConfig":{"host":"####","namePrefix":"","password":"####","port":1883,"prefix":"homeassistant","tls":false,"username":"###"}}
info: Requesting vehicles
info: Vehicle request status {"status":"success"}
info: Connecting to MQTT {"config":{"username":"###","will":{"payload":"false","retain":true,"topic":"homeassistant/######/available"}},"url":"mqtt://#####:1883"}
info: Connected to MQTT
info: Subscribed to command topic {"topic":"homeassistant/#######/command"}
info: Requesting diagnostics
info: Requesting diagnostics
info: Requesting diagnostics
info: Requesting diagnostics
info: Requesting diagnostics
(...)
info: Requesting diagnostics
info: Requesting diagnostics
Thank you
edit: unsure if it's related but the library onstarjs was updated a week ago with a new secret key
https://github.com/samrum/OnStarJS/releases/tag/v2.3.14
edit 2: Got an error
error: Error {"error":{"message":"Request Failed with status 401 - Unauthorized","request":{"method":"POST"},"response":{"data":{"error":"invalid_token"},"headers":{"cache-control":"\"no-store\"","connection":"keep-alive","content-length":"32","content-type":"\"application/json; charset=UTF-8\"","date":"Mon, 09 Jan 2023 05:01:44 GMT","pragma":"\"no-cache\"","request-context":"appId=cid-v1:a7e19842-5b19-4b47-a9cf-85cc6e87a746"},"status":401,"statusText":"Unauthorized"},"stack":"Error: Request Failed with status 401 - Unauthorized\n at RequestService.<anonymous> (/app/node_modules/onstarjs/dist/index.js:594:32)\n at Generator.throw (<anonymous>)\n at rejected (/app/node_modules/onstarjs/dist/index.js:33:65)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}}
Hello,
I just installed the latest version and the job is stuck at requesting vehicle info for the past 5 minutes. In MQTT, I see there's a new entry but this entry says it's available = false.
I'm from Canada and I think we have a different onstar url, could that be the problem?
I'm trying to change my car's charging profile but I'm unable to find the correct way to do so. Could you give us correct way of writing the command? I've tried to check on the onstarjs page but all I'm getting is command error.
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,
I'm looking at my log file and it seems I'm getting an error every now and there. When this happen, the sendCommand also stop working.
Here's what the log file show:
https://pastebin.com/0dnNrTcS
Restarting normally fix the issue, or just wait (sometime it takes many hours before it start working back).
Thank you
I requested the location command feature be added into OnStarJS.
Is it possible to integrate it into your project as well?
Awesome work, thanks.
Hello,
I'm trying to use the new canada api since the usa doesn't work and I'm getting this error at beginning. It seems that even though the variable is passed, it still try to use the gm.com
I'm also unsure api.gm.ca existe because when I try to ping that, I don't get any DNS resolve either on my local DNS or using public DNS.
Thank you
Valid onstar_username, onstar_password, onstar_pin, onstar_vin provided. Getting an "error: Error" from onstar.
I've attached the error from onstar2mqtt and omitted "data", the vin, and the bearer tokens.
THANK YOU for your work on this project! I successfully configured it, and for about 24 hours it functioned correctly. After that, it started returning "car did not respond errors." I figured out that the car needed to be turned on, and it started working again, but only briefly. For 2 days now, it has been consistently returning "unknown system error" (see sanitized json below). I tried giving it a 1-day break, and changed the polling time to 4 hours when the car is garaged, and left it at 30 minutes when the car is out, but it hasn't helped. My Android app is now also failing to update. Both onstar2mqtt and the Android app correctly return the location. I'm not sure if this is a known problem, or if there has been a general outage at GM lasting several days, or if they have blocked my account.
{"error":{"message":"Command Failure","request":{"body":"{}","contentType":"application/json; charset=UTF-8","headers":{},"method":0,"url":"https://api.gm.com/api/v1/account/vehicles/XXXXXXXXXXXXXXXXX/requests/XXXXXXXXXXX"},"response":{"data":{"commandResponse":{"body":{"error":{"code":"ONS-900","description":"Unknown system error"}},"completionTime":"2023-03-15T12:22:31.184Z","requestTime":"2023-03-15T12:22:07.977Z","status":"failure","type":"diagnostics","url":"https://api.gm.com/api/v1/account/vehicles/XXXXXXXXXXXXXXXXX/requests/XXXXXXXXXXX"}},"headers":{"connection":"keep-alive","content-type":"application/json;charset=UTF-8","date":"Wed, 15 Mar 2023 12:22:34 GMT","request-context":"appId=cid-v1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","transfer-encoding":"chunked"},"status":200,"statusText":"OK"},"stack":"Error: Command Failure\n at RequestService. (/app/node_modules/onstarjs/dist/index.js:564:35)\n at Generator.next ()\n at fulfilled (/app/node_modules/onstarjs/dist/index.js:32:58)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}}
Could you add EV ESTIMATED CHARGE END in onstar2mqtt ? It seems it's present in onstar2JS
Regards ! Great job !
It appears that the getLocation command, after being returned, does not get sent to the MQTT broker to be send to device_tracker.
Logging output from the docker container:
info: Command sent {"command":"getLocation"} info: Command completed {"command":"getLocation"} info: Command response data {"data":{"commandResponse":{"body":{"direction":{"uom":"degree","value":"0.0"},"location":{"lat":"42.0000000","long":"-71.0000000"},"speed":{"uom":"kmph","value":"0.0"}},"completionTime":"2023-01-26T05:44:53.336Z","requestTime":"2023-01-26T05:44:50.577Z","status":"success","type":"location","url":"https://api.gm.com:443/api/v1/account/vehicles/MY_VIN/requests/location12345678901234567890"}}} info: Requesting diagnostics
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.