Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
422 stars 85 forks source link

Test start/stop car commands on EV cars #39

Closed fuatakgun closed 2 years ago

fuatakgun commented 3 years ago

Positive posts;

Investigation required;

lars-viklund commented 3 years ago

I did some more testing with the latest version. The problem I mentioned, i.e., defroster status shows as on after stop_climate(), occurs about one in ten times.

However, I also tested starting and stopping the HVAC via the Kia Uvo app a number of times, and then the same thing happens with about the same frequency. Thus, it appears like the problem is on Kia's side, not in the HA integration.

When starting from the app I usually don't stop from the app, which is why I haven't noticed the problem before.

lars-viklund commented 3 years ago

When starting the air con from the app it is possible to select target temperature, defroster on/off, and heating on/off. See the attached screenshot. Would be nice to be able to do the same from the HA integration. Right now it uses whatever settings were used most recently.

tempFileForShare_20210529-234930

fuatakgun commented 3 years ago

Hey, thanks for the update, i would definitely implement these options, it was easier to hardcode some values to enable testing.

About your findings, is it the same with kia uvo app or this is happening only via integration?

What do you see when you click on heating in the screenshot? Can up also share that state?

ratormat commented 3 years ago

Hi, My observation: The payload of start_climate() is used, not the app values. I set defrost = False and heating1 = 0 now in the summer time =) tempCode: 10H leads to 22° C 9H to 18.5 8H to 18 stop_climate() seems not to take defrost and heating1 values in the car. If I call, all is off. Sampled with a Soul EV 2019.

fuatakgun commented 3 years ago

I believe we are in good shape here to enable actual implementation, thank you all.

cdnninja commented 2 years ago

Just in final testing for this feature on the CA side but I have cloned it for the EU side. I plan to create a pull request later this week. I will need a hand testing and reviewing it. I also think it may be a breaking change as it now requires these values.

cdnninja commented 2 years ago

You now need to select the settings. Could you please test? I didn't mean to merge to master but did - oops. It works fine in CA but need a EU test. @fuatakgun

ratormat commented 2 years ago

Thank you! I can test it, but not until two weeks.

lars-viklund commented 2 years ago

I have done some basic testing (turn on everything). Works like a charm. Car is an MY20 e-Niro and I'm located in Sweden.

ratormat commented 2 years ago

So I have done my testing. My car is a KIA eSoul 2019 located in Germany. It runs really good! I checked lock, unlock, start/stop charging, start/stop climate. Degree celsius values are correct. Defrost/Heating switches are working fine. Guess there are some restrictions in start climate:

cdnninja commented 2 years ago

Awesome thanks for the feedback! Yes we will need to find ways to clarify what works in what region. It is amazing how different it is from country to country on the same cars.

Kevr0n228 commented 2 years ago

are the start and stop climate commands available for Hyundai vehicles? I've got a 2019 Hyundai Kona EV and would be happy to test it out if its available. I'm in Canada and the only commands I have in HA are lock/unlock.

cdnninja commented 2 years ago

are the start and stop climate commands available for Hyundai vehicles? I've got a 2019 Hyundai Kona EV and would be happy to test it out if its available. I'm in Canada and the only commands I have in HA are lock/unlock.

Yes for the regions we have build support for. Which country are you from?

Kevr0n228 commented 2 years ago

are the start and stop climate commands available for Hyundai vehicles? I've got a 2019 Hyundai Kona EV and would be happy to test it out if its available. I'm in Canada and the only commands I have in HA are lock/unlock.

Yes for the regions we have build support for. Which country are you from?

Comment has been updated with region, sorry about that!

cdnninja commented 2 years ago

It should work for Canada Hyundai but I haven't personally tested since I have a Canadian Kia.

To test go to developer on the left and click services. It is called start_climate. It also can be used in the gui mode in this section. It can be added elsewhere or called via automation. I would be careful with this one though, as it also starts ICE cars.

Kevr0n228 commented 2 years ago

Ok, just gave it a shot with no success. The request sent and got a success confirmation but the vehicle climate did not start up. I verified that Bluelink itself was able to send the commands properly and get the heat going.

2021-11-01 18:01:13 DEBUG (SyncWorker_2) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Get Vehicle Location {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'head': 131, 'coord': {'lat': 43.514733, 'lon': -80.217717, 'alt': 325.0, 'type': 0}, 'accuracy': {'hdop': 7, 'pdop': 12}, 'time': '20211101214938', 'speed': {'value': 0, 'unit': 0}}} 2021-11-01 18:01:13 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - LastUpdated 2021-11-01 21:45:59+00:00 - Timezone UTC 2021-11-01 18:01:13 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Engine type set VEHICLE_ENGINE_TYPE.EV 2021-11-01 18:01:49 DEBUG (SyncWorker_1) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received Pin validation response <Response [200]> 2021-11-01 18:02:30 DEBUG (SyncWorker_1) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received start_climate response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}} 2021-11-01 18:02:40 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - force_update_loop start 0 5 2021-11-01 18:02:40 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - force_update_loop last_updated 2021-11-01 21:45:59+00:00

The request did wake up the gauge cluster and I heard the compressor start the same way as when I used the Bluelink web service, but after that: nothing.

cdnninja commented 2 years ago

Based on the lack of errors I assume our syntax is correct for a Hyundai EV. This means it could be a few things:

  1. A value isn't enabled to start heat. In a none ICE I would think it would appear like your car, for example I can start my ICE car but have the Heat disabled. On a EV that would show up like what you say. Could you please confirm when you send the command "climate" is enabled and maybe try "heating" as well?
  2. If the first one doesn't fix it I will need both a debug of what was sent and compare it to the app. If you edit custom_components/kia_uvo/KiaUvoApiCA.py and remove the # from 214. Restart and retry will give you more logs. After this we will need to debug the actual bluelink. It can be done by following the steps here: https://github.com/fuatakgun/kia_uvo/wiki/How-to-sniff-API-via-MS-Edge

In particular we are looking for the "rmtstrt" file. It will have details in it much like the debug log will produce in step one. Please post both parts but remove your PIN number as they will contain this.

Kevr0n228 commented 2 years ago

So for #1, I'm calling the service with all options selected - logs show the same as before, climate does not engage.

Screen Shot 2021-11-01 at 7 47 18 PM

for #2, was that a type on "214"? I found a commented debug statement on line 241 and enabled it. Resulting logs are:

2021-11-01 20:08:37 DEBUG (SyncWorker_5) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received Pin validation response <Response [200]> 2021-11-01 20:08:37 DEBUG (SyncWorker_5) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Planned start_climate payload {'setting': {'airCtrl': 1, 'defrost': True, 'heating1': 1, 'igniOnDuration': 5, 'ims': 0, 'airTemp': {'value': '0AH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'XXXX'} 2021-11-01 20:09:18 DEBUG (SyncWorker_5) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received start_climate response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}}

Finally, snooping the comms on the bluelink site yielded this with the settings below: image

Screen Shot 2021-11-01 at 8 20 54 PM
cdnninja commented 2 years ago

Awesome thanks for that! Looks like a few things are slightly different. Hopefully two more things before I start making some coding changes.

  1. The very first rmtst request. Does it have that transaction section as well?
  2. Could I get the rest of that view for rmtst, thinking what is below airTempUnit.

It looks like your car is using slightly different values on this. Now I will dig in to see if this is a kia vs hyundai thing or a EV vs ICE thing. I really appreciate the testing and patience on this!

Kevr0n228 commented 2 years ago

No problem! Thanks for all the work getting done on this project, I've been trying to find a way to ditch Hyundai's terrible app for a while now so anything towards that end is no trouble at all!

Here are all the rmtsts in order: image image image

and the grand finale: image

cdnninja commented 2 years ago

Interesting! This seems to be different than bluelinky as well. What does rfon show? I think rmtsts is being used to validate it worked only since your first request is just a status update check. In my Kia that command starts the car.

On Nov 1, 2021, at 8:01 PM, Kevin @.***> wrote:

 No problem! Thanks for all the work getting done on this project, I've been trying to find a way to ditch Hyundai's terrible app for a while now so anything towards that end is no trouble at all!

Here are all the rmtsts in order:

and the grand finale:

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Kevr0n228 commented 2 years ago
Screen Shot 2021-11-01 at 10 44 16 PM
cdnninja commented 2 years ago

Sorry for the wild goose chase. I am wondering if the preview tab isn't showing the request but only the response? Could you check the "headers" tab particularly the first rmtsts for something similar to:

{'setting': {'airCtrl': 1, 'defrost': True, 'heating1': 1, 'igniOnDuration': 5, 'ims': 0, 'airTemp': {'value': '0AH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'XXXX'}

Kevr0n228 commented 2 years ago

I think I got it, it was in the rfon header: image

cdnninja commented 2 years ago

Yes! That looks correct. Also looks pretty much identical to the Kia. In the file you edited before could you edit line 213 to change it from rmtstrt to rfon? I think it may work with just that change. If so I will test the Kia side to see if it works or if I need to tinker.

Kevr0n228 commented 2 years ago

ok, I updated line 213 to url = self.API_URL + "rfon" #"rmtstrt", but after restarting the ha core and re-running the service I got hit with a bunch of errors in the logs and the climate did not start.

log file: UVO_logs.txt

cdnninja commented 2 years ago

May be easier to do a quick call if you are up for it. That being said I missed they are calling the data hvacInfo instead of "setting" that is line 225 in the API file. After that I am interested in what hvacTempType means as yours is different than what mine has.

Kevr0n228 commented 2 years ago

Sure, I'm down to set something up - whats the best way to reach you so we can plan a time and platform to call on?

cdnninja commented 2 years ago

Path was wrong, I found something in a bluelinky issue. Try this version of the file: https://github.com/cdnninja/kia_uvo/blob/EV-Start/custom_components/kia_uvo/KiaUvoApiCA.py

This is hard coded for EVs right now but comes back success even on my ICE (doesn't start it though).

Kevr0n228 commented 2 years ago

Alright! That got it going. Climate, Temperature and Defrost all work as expected. Setting a duration did not seem to work, at least not how I expected: I set it to run for 1 minute and it kept on going well after that. Heated features activated the rear window heater, but not the heated steering wheel. When I triggered it, I saw that the steering wheel heat button was flashing instead of solid, and after a few minutes the wheel was still cold. I tried doing it with the Bluelink web app afterwards and got the same result, so this may be a problem with Bluelink and not the integration.

cdnninja commented 2 years ago

Duration doesn’t exist in the blue link app so it doesn’t work in home assistant.

I will find a way to document this though. I also need to do some work so it uses the right method for ev vs ice.

Thanks for testing! I’ll let you know when the main release should have this solved.

On Nov 2, 2021, at 8:20 PM, Kevin @.***> wrote:

 Alright! That got it going. Climate, Temperature and Defrost all work as expected. Setting a duration did not seem to work, at least not how I expected: I set it to run for 1 minute and it kept on going well after that. Heated features activated the rear window heater, but not the heated steering wheel. When I triggered it, I saw that the steering wheel heat button was flashing instead of solid, and after a few minutes the wheel was still cold. I tried doing it with the Bluelink web app afterwards and got the same result, so this may be a problem with Bluelink and not the integration.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Kevr0n228 commented 2 years ago

No problem! Thanks for your patience helping me get it going. One more thing, I tried stop_climate and it did not work. Logs show this: 2021-11-02 22:57:02 DEBUG (SyncWorker_6) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received Pin validation response <Response [200]>

2021-11-02 22:57:25 DEBUG (SyncWorker_6) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received stop_climate response 6539

I think it could be a similar issue that we were having with start_climate as theres no message in the log with the actual pin and commands.

cdnninja commented 2 years ago

Just to follow up on this. @Kevr0n228 switched to email for a bit for more testing. This CA EV issue should be solved now.

fuatakgun commented 2 years ago

Can we resolve this?

Kevr0n228 commented 2 years ago

I haven't had a chance to try out the start/stop charge commands yet, but climate seems to be working properly.

On Fri., Nov. 19, 2021, 09:46 Fuat Akgün, @.***> wrote:

Can we resolve this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fuatakgun/kia_uvo/issues/39#issuecomment-974132983, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACP3WYWY44O3RD6IKMKXI3TUMZPLHANCNFSM45MAH2YA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.