Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TaiPhamD
Copy link

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

@synchronizing
Copy link
Owner

synchronizing commented Dec 18, 2022

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).

@TaiPhamD
Copy link
Author

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

@synchronizing
Copy link
Owner

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

@TaiPhamD
Copy link
Author

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.

@synchronizing
Copy link
Owner

synchronizing commented Jan 7, 2023

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

@synchronizing
Copy link
Owner

synchronizing commented Jan 7, 2023

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?

@TaiPhamD
Copy link
Author

TaiPhamD commented Jan 7, 2023

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
Copy link
Author

TaiPhamD commented Jan 7, 2023

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)

@synchronizing
Copy link
Owner

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:

# Retrieves car information.
cars = {}
for info in json["RESPONSE_STRING"]["OwnersVehiclesInfo"]:
car = Car(
nickname=info["VehicleNickName"],
model=info["Name"],
year=info["Year"],
vin=info["VinNumber"],
uid=info["RegistrationID"],
bluelink=bool(info["IsBlueLinkCar"]),
_auth=self._auth,
_info=info,
_session=self._session,
)
cars[info["VinNumber"]] = car

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. 😄

Repository owner deleted a comment from p4u1d34n Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants