samrum / OnStarJS

NodeJS Library for making OnStar API requests
MIT License
85 stars 17 forks source link

Alert Function Does Not Work #207

Closed BigThunderSR closed 1 year ago

BigThunderSR commented 1 year ago

Sorry if this is a duplicate as I wasn't sure where this issue needs to be opened.

From: https://github.com/michaelwoods/onstar2mqtt/issues/218

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| }

I changed the following code in commands.js from:

async alert({action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
             delay = 0, duration = 1, override = []}) {
    return this.onstar.alert({
        action,
        delay,
        duration,
       override
    });
}

To:

async alert({action = [Commands.CONSTANTS.ALERT_ACTION.FLASH]}) {
    return this.onstar.alert({action});  
}

Which worked to trigger only the flashing lights.

BigThunderSR commented 1 year ago

Looks like this issue isn't because of OnStarJS, so I should not have opened this issue here. Sorry for my error.