bluelink icon indicating copy to clipboard operation
bluelink copied to clipboard

update service id for start/stop action to match current USA endpoint

Open TaiPhamD opened this issue 3 years ago • 9 comments

Based on latest network inspection the service ID have changed which will make this code get an error. The ID is updated to fix this problem.

Example of the current raw ID:

# sending remote start:
Request Data
MIME Type: application/x-www-form-urlencoded; charset=UTF-8
vin: KMXXXXX
username: xxxx
token: JWT-xxxxxx
pin: xxxxx
url: https://owners.hyundaiusa.com/us/en/page/blue-link.html
airCtrl: true
igniOnDuration: NaN
airTempvalue: 72
defrost: false
heating1: 0
gen: 2
regId: H00xxxxxxxxx
seatHeaterVentInfo: {"drvSeatHeatState":"2"}
service: postRemoteFatcStart

TaiPhamD avatar Dec 18 '22 15:12 TaiPhamD

Hey @TaiPhamD, thank you for the MR. Quick question: Is your Hyundai vehicle bought in the United States? (Different regions seem to have different APIs).

synchronizing avatar Dec 18 '22 15:12 synchronizing

Hey @TaiPhamD, thank you for the MR. Quick question: Is your Hyundai vehicle bought in the United States? (Different regions seem to have different APIs).

Yes it is bought from the US

TaiPhamD avatar Dec 18 '22 17:12 TaiPhamD

I just ran some tests on the existing codebase, and things are working as expected for a 2021 Elantra. What car do you have?

synchronizing avatar Dec 21 '22 11:12 synchronizing

I just ran some tests on the existing codebase, and things are working as expected for a 2021 Elantra. What car do you have?

I have an Ioniq 5. The apis must be different even between car models. Might need a dictionary for action verbs variability depending on the car model.

TaiPhamD avatar Dec 21 '22 11:12 TaiPhamD

Out of curiosity, when using ignitionstart instead of postRemoteFatcStart, what occurs?

synchronizing avatar Jan 07 '23 16:01 synchronizing

Would you mind adding an if/else in the start function to check for the car's model string? Since I don't have access to your car, I'm unsure what the API sets for the Ioniq 5. Something like:

if self.model == "ioniq5": # Not sure what the `self.model` should be.
    action = "postRemoteFatcStart"
else:
    action = "ignitionstart"

self._request(
    action,
    headers={ ... }
    ...
)

For the stop function, is ignitionstop functional?

synchronizing avatar Jan 07 '23 16:01 synchronizing

Out of curiosity, when using ignitionstart instead of postRemoteFatcStart, what occurs?

You get a 200 OK response code however with an empty response in the body instead of the usual Z-Success response struct. The action also doesn't get logged at all the the action remote history from the bluelink app.

For the stop function, is ignitionstop functional?

No. You get this error if I don't use postRemoteFatcStop on the ioniq 5.

{"E_IFRESULT":"E:Failure","E_IFFAILMSG":"Bad
Gateway","RESPONSE_STRING":{"errorSubCode":"GEN","systemName":"BLODS","errorSubMessage":"Feature Status is
OFF","errorMessage":"Your vehicle does not support this feature.","errorCode":502}}

TaiPhamD avatar Jan 07 '23 16:01 TaiPhamD

Rather than using if else statement in order to easier support multiple models. Could you list me the exact name of the Electra model?

I think we can add this in the constructor:

        # create a dictionary of start/stop action based on car model
        self.start_dict = {"IONIQ 5": "postRemoteFatcStart", "ELENTRA": "ignitionstart"}
        self.stop_dict = {"IONIQ 5": "postRemoteFatcStop", "ELENTRA": "ignitionstop"}

Then in the action code just set:

        action = self.start_dict[self.model]
        # default action if model is not found
        if action is None:
            action = "ignitionstart"

Side note: Thanks to your repo it gave me the idea to write a web proxy server so I can use Siri commands to send remote action to my car to start/stop climate etc. You might find it useful:

https://github.com/TaiPhamD/bluelink_proxy_server)

TaiPhamD avatar Jan 07 '23 17:01 TaiPhamD

No. You get this error if I don't use postRemoteFatcStop on the ioniq 5.

Got it.

Rather than using if else statement in order to easier support multiple models. Could you list me the exact name of the Electra model?

My one concern with this method is that the dictionary will not default, and we would have to - over time - collect all the different car models. I think we can safely assume that if the car is electric it uses postRemoteFatcStart, and otherwise it will use ignitionstart. I unfortunately sold my Elantra, so I no longer have access to the API.

If you don't mind doing some exploration, perhaps here:

https://github.com/synchronizing/bluelink/blob/1d8a8901b8ce39e1aa610e0e0e973df9553b68ea/bluelink/bluelink.py#L339-L353

You can do a print of the entire payload, and see if there is any flag for electric. If so, I think we can pass an electric flag to the Car object, and if/else on that new variable inside the start and stop function. What do you think?

Side note: Thanks to your repo it gave me the idea to write a web proxy server so I can use Siri commands to send remote action to my car to start/stop climate etc. You might find it useful: https://github.com/TaiPhamD/bluelink_proxy_server)

Wow, this is actually awesome! I never got around to it, but I had always wanted to write a layer for Google Home to start my car with seat warmers, air setting, etc. set. Happy to see this package is being used for some cool stuff. 😄

synchronizing avatar Jan 08 '23 17:01 synchronizing