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
432 stars 85 forks source link

start_climate not working on 2.0.1 on EV #386

Closed zadigre closed 1 year ago

zadigre commented 1 year ago

I'm in Canada. Kona Electric 2021

climate not working with 2.0.1. error in the log regarding importing platform custom_components.kia_uvo.climate

2022-10-29 12:38:39.671 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.kia_uvo.climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 722, in get_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 739, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 879, in exec_module File "", line 1017, in get_code File "", line 947, in source_to_code File "", line 241, in _call_with_frames_removed File "/config/custom_components/kia_uvo/climate.py", line 216 self.vehicle.air_control_is_on = True IndentationError: unexpected indent 2022-10-29 12:38:39.673 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform kia_uvo.climate: Platform not found (Exception importing custom_components.kia_uvo.climate).

got this error in the log right after installing 2.0.1 and restarting home assistant

cdnninja commented 1 year ago

As a note on this. The start_climate command still works from my testing. Just not the new climate control.

zadigre commented 1 year ago

I'm not sure to understand what you meant by "still works from my testing"...

fyi, now I'm getting this error when trying to start climate: 2022-10-30 17:05:47.661 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response <Response [200]> 2022-10-30 17:05:47.662 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Planned start_climate payload {'setting': {'airCtrl': 1, 'defrost': None, 'heating1': 'Steering Wheel and Rear Window', 'igniOnDuration': 15, 'ims': 0, 'airTemp': {'value': '0EH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'XXXX'} 2022-10-30 17:05:48.240 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received start_climate response {'error': {'errorCode': '6452', 'errorDesc': 'We apologize, but your request could not be processed. Please try again. If the issue persists, contact Customer Support in the "Help" section.'}, 'responseHeader': {'responseCode': 1, 'responseDesc': 'Failure'}}

cdnninja commented 1 year ago

My car starts right up but it is an ICE car. Typically the error you showed is a parameter issue which is hard to pin down via code. Looks like a value out of range issue. heating1 was supposed to be mapped. (mine doesn't support this). If you don't pass "heating" it may work while I fix that.

I removed your pin from your post.

zadigre commented 1 year ago

thank you for the pin...

Capture d’écran, le 2022-10-30 à 17 41 32

as you can see, there's not that many options.

on the web, lets say I set temperature to 20, climate, defrost and heated, playload is this: hvacInfo: {airCtrl: 1, defrost: true, airTemp: {value: "0CH", unit: 0, hvacTempType: "1"}, heating1: 1}

the integration is sending a lot more than that... for example duration is 15 minutes by default on my car and there's no way to change this.

cdnninja commented 1 year ago

I have updated the services to map the values as above "heating" should have been mapped to 1. You can force this in the yaml as well. If the option doesn't exist for your car don't use it so far that seems to be okay, but wouldn't doubt it if that changes.

cdnninja commented 1 year ago

I have removed the climate platform for now since it looks like it needs some real work to get it going. The start_climate remains like before. I will make a final release for tonight with these tweaks and work on this more later this week. Hopefully this is enough to close this one out though.

zadigre commented 1 year ago

start_climate still not working after updating to 2.0.5 also, for stop_climate, it does't appear to be working. no error in the log... but it does stop climate that may be already running (either started through the app or web).

zadigre commented 1 year ago

edited my previous comment... stop climate service does stop climate when it's already running (ex started with the MyHyundai app)... wrote "it doesn't" before.

that said, I tried start climate with 2.0.6. same error still present.

cdnninja commented 1 year ago

I am not sure if this will change anything on charge or climate but as I was trying to figure this out today I tested my lock action. It was failing this AM. It for sure worked just a few days ago. I did some comparing and noticed this API was hitting. the URL without www. in front. After changing that my lock resumed working - could have been a timing thing though.

I have tested, lock unlock start and stop climate on my ICE in canada and all work fine right now. Could you retest with the latest version?

cdnninja commented 1 year ago

As a note I also added more logging for CA in case it fails.

zadigre commented 1 year ago

climate_start did not work with 2.0.10 chose my vehicle, duration not checked, climate switch enabled, temperature set to 21, defrost checked and enabled. door lock/unlock always worked fine for me.

here's the log: 2022-11-02 18:45:50.037 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': 'access token here', 'pAuth': 'pAuth string here'} 2022-11-02 18:45:50.713 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'pAuth string here'}} 2022-11-02 18:45:50.714 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Planned start_climate payload {'setting': {'airCtrl': 1, 'defrost': None, 'heating1': 0, 'igniOnDuration': 5, 'ims': 0, 'airTemp': {'value': '0EH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'my pin here'} 2022-11-02 18:45:51.409 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received start_climate response {'error': {'errorCode': '6452', 'errorDesc': 'We apologize, but your request could not be processed. Please try again. If the issue persists, contact Customer Support in the "Help" section.'}, 'responseHeader': {'responseCode': 1, 'responseDesc': 'Failure'}}

cdnninja commented 1 year ago

This one looks to be a payload difference pretty quickly:

Planned start_climate payload {'setting': {'airCtrl': 1, 'defrost': None, 'heating1': 0, 'igniOnDuration': 5, 'ims': 0, 'airTemp': {'value': '0EH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'my pin here'}

vs what you posted that works:

hvacInfo: {airCtrl: 1, defrost: true, airTemp: {value: "0CH", unit: 0, hvacTempType: "1"}, heating1: 1}.

So my first few things that I will dig into on a code side is not forcing a igniOnDuration default and also fixing "defrost" as None isn't a valid option. hvacTempType is different too but not sure what that does.

In the meantime could you try a test where you have defrost parameter enabled?

cdnninja commented 1 year ago

Are you able to retest this one?

zadigre commented 1 year ago

still not working with latest 2.0.19

2022-11-07 19:18:54.592 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': 'access token here', 'vehicleId': 'qLHNk/TY2fGJeLL1FVGDXA==', 'pAuth': 'vvjxZHJdHIdndxylEYkbyHhdCUYeZZwL'} 2022-11-07 19:18:55.181 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'IkyawXgymwEgBBDBSWUgKEgRKhppDCGQ'}} 2022-11-07 19:18:55.182 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Planned start_climate payload {'setting': {'airCtrl': 1, 'defrost': False, 'heating1': 0, 'igniOnDuration': 5, 'ims': 0, 'airTemp': {'value': '0EH', 'unit': 0, 'hvacTempType': 0}}, 'pin': 'XXXX} 2022-11-07 19:18:55.706 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received start_climate response {'error': {'errorCode': '6452', 'errorDesc': 'We apologize, but your request could not be processed. Please try again. If the issue persists, contact Customer Support in the "Help" section.'}, 'responseHeader': {'responseCode': 1, 'responseDesc': 'Failure'}} 2022-11-07 19:18:55.708 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 3995.708244

cdnninja commented 1 year ago

Well I figured this one out. Was right in front of me the whole time. EVs need hvacInfo instead of settings in the payload. This was in my post two up but I missed it. I have since corrected that for EVs. If this update works for you or atleast makes the logs show hvacInfo it proves the APIs are updating as this is a fix in the underlying interface and not in the home assistant code. Release will be out in a few minutes.

zadigre commented 1 year ago

some progress... success in the log but getting this weird error popup in the app after trying in HA: IMG_3120

and yes all doors, trunk and hood are closed/locked. this is with climate switch on, temperature at 21.5, defrost on and enabled... which give me this in yaml: service: kia_uvo.start_climate data: temperature: 21.5 defrost: true device_id: c5ecad382e823ad854e7ba7dc8c2cbcd

start climate works fine inside the app.

log: 2022-11-07 21:24:00.595 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': 'access token here', 'vehicleId': 'qLHNk/TY2fGJeLL1FVGDXA==', 'pAuth': 'CjEaeKxNQkrQmVmAqbNjSWTWeTiwSxMF'} 2022-11-07 21:24:01.217 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'yPAIpAMHpDBzoVHPSlzKEwaxSxUMAmSd'}} 2022-11-07 21:24:01.217 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Planned start_climate payload {'hvacInfo': {'airCtrl': 1, 'defrost': False, 'heating1': 0, 'airTemp': {'value': '0FH', 'unit': 0, 'hvacTempType': 1}}, 'pin': 'XXXX'} 2022-11-07 21:24:02.034 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received start_climate response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}} 2022-11-07 21:24:02.037 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 316.037462 2022-11-07 21:24:02.734 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20221108021954', 'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '00H', 'unit': 0}, 'defrost': True, 'acc': False, 'evStatus': {'batteryCharge': False, 'batteryStatus': 72, 'batteryPlugin': 0, 'remainTime2': {'etc1': {'value': 15, 'unit': 1}, 'etc2': {'value': 295, 'unit': 1}, 'etc3': {'value': 60, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'gasModeRange': {'value': 0.0, 'unit': 1}, 'evModeRange': {'value': 383.0, 'unit': 1}, 'totalAvailableRange': {'value': 383.0, 'unit': 1}}, 'type': 2}]}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {}, 'tirePressureLamp': {'tirePressureLampAll': 0}, 'battery': {'batSoc': 85, 'batState': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {}, 'sleepModeCheck': False, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineRuntime': {}}}} 2022-11-07 21:24:02.734 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: 2022-11-08 02:18:46+00:00 2022-11-07 21:24:02.735 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - before 20221108021954 2022-11-07 21:24:02.735 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - after 2022-11-08 02:19:54+00:00 2022-11-07 21:24:02.735 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2022-11-08 02:19:54+00:00 2022-11-07 21:24:03.365 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'msopServiceOdometer': 48081.0, 'msopServiceOdometerUnit': 1, 'mtspServiceDate': '20220819', 'imatServiceOdometer': 60081.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20230219', 'currentOdometer': 54029.2, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 12000.0, 'serviceDaysDuration': 184, 'serviceMonthsThreshold': 6}}} 2022-11-07 21:24:03.367 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.331 seconds (success: True)

zadigre commented 1 year ago

how now I'm not sure what is going one... but getting an error when trying start_climate service and also this in the log (after my pin)

/edit apparently it might be a bug in home assistant... tried with Edge, worked fine. tried again... same bug. tried with Chrome, worked fine. or I'm lucky/not lucky.

2022-11-07 21:48:10.900 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, kwargs) File "/usr/local/lib/python3.10/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/kia_uvo/services.py", line 65, in async_handle_start_climate await coordinator.async_start_climate(vehicle_id, climate_request_options) File "/config/custom_components/kia_uvo/coordinator.py", line 119, in async_start_climate await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 96, in start_climate return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 486, in start_climate response = response.json() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2022-11-07 21:48:10.914 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139753217483312] Error handling message: Unknown error (unknown_error) from 192.168.25.18 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, kwargs) File "/usr/local/lib/python3.10/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 646, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/kia_uvo/services.py", line 65, in async_handle_start_climate await coordinator.async_start_climate(vehicle_id, climate_request_options) File "/config/custom_components/kia_uvo/coordinator.py", line 119, in async_start_climate await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 96, in start_climate return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 486, in start_climate response = response.json() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

cdnninja commented 1 year ago

So the json appears to mean the API response came back very odd so it can't decode it. Next update will have a log line before we try decoding we can figure out why this happens. The API may tell us.

I was digging and found the changes I remembered awhile back on this. In that time I found this mention from last year: https://github.com/fuatakgun/kia_uvo/issues/214#issuecomment-998213904

What stands out to me is your mention of defrost needs to be enabled. I looked up above and saw your mentioned defrost was enabled but in the logs it says it past enabled.

Could you try pass:

service: kia_uvo.start_climate data: defrost: true device_id: c5ecad382e823ad854e7ba7dc8c2cbcd temperature: 21 heating: "1" climate: true

Thanks for sticking with this. Greatly appreciate your time.

zadigre commented 1 year ago

here's what I put in yaml mode. service: kia_uvo.start_climate data: temperature: 21.5 climate: true defrost: true device_id: c5ecad382e823ad854e7ba7dc8c2cbcd heating: "1"

but log says defrost false... and a bunch of errors after that. it may be climate true that cause all these errors because if I remove it, service is called properly... but it still fails with this popup I receive in the app after 60-90 seconds.

Also if I try to use start climate through the ui, call service is greyed out. I can still start service. I should have told you... it has been like that pretty much since the beginning with 2.0.x with start climate. Maybe some data validation errors? It's only start climate that has this problem... all other services I've tried have the blue call service button.

I don't know what I did exactly... but at some point it was blue yesterday and today. I remove everything from the yaml mode and it's greyed out again.

2022-11-08 06:09:53.713 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': 'access token here', 'pAuth': 'LyaPsLuJlbiRjAPFsfYPcrPFAkMUiXSc'} 2022-11-08 06:09:54.436 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'kCrCPcYXxLnsXLKuaPrWNmYNyrnPbTVP'}} 2022-11-08 06:09:54.437 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Planned start_climate payload {'hvacInfo': {'airCtrl': True, 'defrost': False, 'heating1': '1', 'airTemp': {'value': '0FH', 'unit': 0, 'hvacTempType': 1}}, 'pin': 'XXXX'} 2022-11-08 06:09:56.327 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, kwargs) File "/usr/local/lib/python3.10/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/kia_uvo/services.py", line 65, in async_handle_start_climate await coordinator.async_start_climate(vehicle_id, climate_request_options) File "/config/custom_components/kia_uvo/coordinator.py", line 119, in async_start_climate await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 96, in start_climate return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 486, in start_climate response = response.json() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2022-11-08 06:09:56.332 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139752838789632] Error handling message: Unknown error (unknown_error) from 192.168.25.18 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, kwargs) File "/usr/local/lib/python3.10/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 646, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/kia_uvo/services.py", line 65, in async_handle_start_climate await coordinator.async_start_climate(vehicle_id, climate_request_options) File "/config/custom_components/kia_uvo/coordinator.py", line 119, in async_start_climate await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 96, in start_climate return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 486, in start_climate response = response.json() File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

cdnninja commented 1 year ago

I made some progress on this. Had some mapping issues as well was setting the one value to the wrong type. Latest is an improvement - considering how many times I have had fixes I make no promises. Confirmed working on my ICE car.

zadigre commented 1 year ago

success!!! DON'T TOUCH ANYTHING ELSE!! 😂

even the shown set temperature is right (same as inside the car).

zadigre commented 1 year ago

you might need to touch something after all... stop climate doesn't look like it's working... stop climate service doesn't stop climate now... I have to stop trough the app.

here's the log after stop climate 👍 2022-11-09 22:01:34.297 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': ' access token here ', 'vehicleId': 'qLHNk/TY2fGJeLL1FVGDXA==', 'pAuth': 'tsgSByxAmajMzgQAATnxEtLGMrifAdMj'} 2022-11-09 22:01:34.877 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'LfkpDMqickEQgNStFfzqQmDrgjndHCJd'}} 2022-11-09 22:01:35.847 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received stop_climate response 2022-11-09 22:01:35.850 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.VehicleManager] time diff - 161.849912 2022-11-09 22:01:36.533 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20221110025854', 'airCtrlOn': True, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '0BH', 'unit': 0}, 'defrost': True, 'acc': False, 'evStatus': {'batteryCharge': False, 'batteryStatus': 88, 'batteryPlugin': 0, 'remainTime2': {'etc1': {'value': 0, 'unit': 1}, 'etc2': {'value': 520, 'unit': 1}, 'etc3': {'value': 115, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'gasModeRange': {'value': 0.0, 'unit': 1}, 'evModeRange': {'value': 443.0, 'unit': 1}, 'totalAvailableRange': {'value': 443.0, 'unit': 1}}, 'type': 2}]}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {}, 'tirePressureLamp': {'tirePressureLampAll': 0}, 'battery': {'batSoc': 80, 'batState': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {}, 'sleepModeCheck': False, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineRuntime': {}}}} 2022-11-09 22:01:36.534 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: 2022-11-10 02:58:54+00:00 2022-11-09 22:01:36.534 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - before 20221110025854 2022-11-09 22:01:36.534 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - after 2022-11-10 02:58:54+00:00 2022-11-09 22:01:36.534 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2022-11-10 02:58:54+00:00 2022-11-09 22:01:37.091 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'msopServiceOdometer': 48081.0, 'msopServiceOdometerUnit': 1, 'mtspServiceDate': '20220819', 'imatServiceOdometer': 60081.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20230219', 'currentOdometer': 54107.3, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 12000.0, 'serviceDaysDuration': 184, 'serviceMonthsThreshold': 6}}} 2022-11-09 22:01:37.094 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.246 seconds (success: True)

cdnninja commented 1 year ago

I added a tiny bit more logging in the next version for stop climate. It will now show the response the server provides. Please post that. Glad we are making progress!

zadigre commented 1 year ago

here's the log after a stop climate with latest version:

2022-11-10 06:31:54.568 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Pin Headers {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, /', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'mybluelink.ca', 'origin': 'https://mybluelink.ca', 'referer': 'https://mybluelink.ca/login', 'from': 'SPA', 'language': '0', 'offset': '0', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'accessToken': ' access token here ', 'pAuth': 'NoAuaQOvJTdYBQRgAKjdbrpjKsgKgIfn'} 2022-11-10 06:31:55.981 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'EbJrDBbCLzOrCcppwNqtsfCXpcXgeRii'}} 2022-11-10 06:31:57.949 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received stop_climate response: {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}} 2022-11-10 06:31:57.952 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.VehicleManager] time diff - 466.95254 2022-11-10 06:31:58.679 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20221110112618', 'airCtrlOn': True, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '0BH', 'unit': 0}, 'defrost': True, 'acc': False, 'evStatus': {'batteryCharge': False, 'batteryStatus': 88, 'batteryPlugin': 0, 'remainTime2': {'etc1': {'value': 0, 'unit': 1}, 'etc2': {'value': 0, 'unit': 1}, 'etc3': {'value': 0, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'gasModeRange': {'value': 0.0, 'unit': 1}, 'evModeRange': {'value': 442.0, 'unit': 1}, 'totalAvailableRange': {'value': 442.0, 'unit': 1}}, 'type': 2}]}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {}, 'tirePressureLamp': {'tirePressureLampAll': 0}, 'battery': {'batSoc': 80, 'batState': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {}, 'sleepModeCheck': False, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineRuntime': {}}}} 2022-11-10 06:31:58.679 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: 2022-11-10 11:24:11+00:00 2022-11-10 06:31:58.679 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - before 20221110112618 2022-11-10 06:31:58.679 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - after 2022-11-10 11:26:18+00:00 2022-11-10 06:31:58.680 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2022-11-10 11:26:18+00:00 2022-11-10 06:32:00.154 DEBUG (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'msopServiceOdometer': 48081.0, 'msopServiceOdometerUnit': 1, 'mtspServiceDate': '20220819', 'imatServiceOdometer': 60081.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20230219', 'currentOdometer': 54107.3, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 12000.0, 'serviceDaysDuration': 184, 'serviceMonthsThreshold': 6}}} 2022-11-10 06:32:00.155 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 2.204 seconds (success: True)

cdnninja commented 1 year ago

Found what I think was root cause on stop_climate for EVs and resolved it.

zadigre commented 1 year ago

progress progress!! success for both start and stop charge.

cdnninja commented 1 year ago

Awesome. I'll close the charge one out. Let me know if stop_climate also works.

zadigre commented 1 year ago

Start stop climate works fine too!

cdnninja commented 1 year ago

Great thanks for sticking with this! I think you have a few feature requests or other items open. My priority will be getting the other bugs that have been reported done for 2.X stream. Once it feels stable and not many new reports this stream will get rolled out as the new branch and I can go back and start adding more items that needed this redesign to work.