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

hyundai canada problem #161

Closed olivierjag2 closed 2 years ago

olivierjag2 commented 2 years ago

Trying to set up integration in UI not working,

Login using bluelinky or bluelink web app works.

Message is: Unknown error occurred

olivierjag2 commented 2 years ago

Logger: homeassistant.config_entries Source: custom_components/kia_uvo/init.py:198 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 15:00:17 (1 occurrences) Last logged: 15:00:17

Error setting up entry for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/init.py", line 209, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 198, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

olivierjag2 commented 2 years ago

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:69 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 15:00:17 (1 occurrences) Last logged: 15:00:17

kia_uvo - Exception in update : 'msopServiceOdometerUnit' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 146, in get_cached_vehicle_status vehicle_status["lastService"]["unit"] = response["msopServiceOdometerUnit"] KeyError: 'msopServiceOdometerUnit'

cdnninja commented 2 years ago

Could you post a copy of the response data? It should be in the logs above that second error and look something like this: https://github.com/fuatakgun/kia_uvo/wiki/Example-Data Block out GPS data if it exists.

olivierjag2 commented 2 years ago

where I found this respond? I look in the journal and I don't find respond exept two same error

simille83 commented 2 years ago

I also had problems after the last update, when restarting home Assistant is unable to load the integration, errore b4 in the log. I tried to delete it to install it from scratch but the interface reports the error "unable to load the configuration flow". With the previous version everything worked perfectly.

cdnninja commented 2 years ago

Enable debug logging outlined on the home page of GitHub. It should then be in the core log.

cdnninja commented 2 years ago

@simille83 which region and brand are you using?

olivierjag2 commented 2 years ago

canada hyundai, I test wity my canada kia and all works fine

cdnninja commented 2 years ago

Could I get the "Get Service status data" response?

cdnninja commented 2 years ago

I suspect Hyundai doesn't offer the next service data point.

olivierjag2 commented 2 years ago

Kia Uvo / Hyundai Bluelink: update doest work

cdnninja commented 2 years ago

I am going to need more detail than that. This is currently functioning for me in Canada on Kia.

olivierjag2 commented 2 years ago

I have error with hyundai

Logger: homeassistant.config_entries Source: custom_components/kia_uvo/init.py:198 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 16:05:20 (1 occurrences) Last logged: 16:05:20

Error setting up entry xxxxx@hotmail.com for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/init.py", line 209, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 198, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:69 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 16:05:20 (1 occurrences) Last logged: 16:05:20

kia_uvo - Exception in update : 'msopServiceOdometerUnit' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 146, in get_cached_vehicle_status vehicle_status["lastService"]["unit"] = response["msopServiceOdometerUnit"] KeyError: 'msopServiceOdometerUnit'

cdnninja commented 2 years ago

Please enable debug logging. View the core debug logs and provide the dump including "Get Service status data".

Debug logging can be done by adding the code at the bottom of this page: https://github.com/fuatakgun/kia_uvo

Logging can be viewed by going Supervisor--> System and select core.

olivierjag2 commented 2 years ago

2021-11-19 16:28:33 DEBUG (MainThread) [custom_components.kia_uvo] kia_uvo - async_setup_entry started - <homeassistant.config_entries.ConfigEntry object at 0x7f9d9b8c8670> REDACTED 2021-11-19 16:28:33 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Received token into Vehicle Object ', 'device_id': None, 'vehicle_name': '', 'vehicle_id': '==', 'vehicle_regid': None, 'vehicle_model': ', 'vehicle_registration_date': 'missing', 'stamp': 'NoStamp'} 2021-11-19 16:28:33 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Refresh token started 2021-11-20 14:03:15.230121 2021-11-19 16:28:33.863638 False 2021-11-19 16:28:33 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Refresh token started 2021-11-20 14:03:15.230121 2021-11-19 16:28:33.863751 False 2021-11-19 16:28:34 WARNING (SyncWorker_1) [custom_components.sinope] Error code: 7ffc (None or invalid value for 5ebb0000), Data:(550015004102529087230a01005ebb0000070802000002fc7fb9) 2021-11-19 16:28:34 WARNING (MainThread) [homeassistant.components.environment_canada] Environment Canada YAML configuration is deprecated; your YAML configuration has been imported into the UI and can be safely removed 2021-11-19 16:28:35 WARNING (MainThread) [homeassistant.components.tplink] The 'tplink' option near /config/configuration.yaml:1 is deprecated, please remove it from your configuration 2021-11-19 16:28:36 DEBUG (SyncWorker_0) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20211119145414', 'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '01H', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 416.0, 'unit': 1}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 81, 'batState': 0, 'sjbDeliveryMode': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'sleepModeCheck': True, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineOilStatus': False, 'vehicleMovementHis': True, 'engineRuntime': {'value': 29, 'unit': 1}}}} 2021-11-19 16:28:38 DEBUG (SyncWorker_0) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'mtspServiceDate': '20210917', 'imatServiceOdometer': 6000.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20220317', 'currentOdometer': 2213.899902, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 6000.0, 'serviceDaysDuration': 181, 'serviceMonthsThreshold': 6}}} 2021-11-19 16:28:38 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'msopServiceOdometerUnit' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 146, in get_cached_vehicle_status vehicle_status["lastService"]["unit"] = response["msopServiceOdometerUnit"] KeyError: 'msopServiceOdometerUnit'

2021-11-19 16:28:38 ERROR (MainThread) [homeassistant.config_entries] Error setting up entryxxxxx@hotmail.com for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/init.py", line 209, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 198, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

cdnninja commented 2 years ago

Please test with the code in #163 and let me know if it resolves it. Looks like your car is so new you haven't had service yet. Congrats! I have edited your comment to remove the tokens.

simille83 commented 2 years ago

2021-11-19 22:47:13 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration kia_uvo: No module named 'bs4'

simille83 commented 2 years ago

@simille83 which region and brand are you using?

Europe, i have kia e-Niro

olivierjag2 commented 2 years ago

no same error, I modify the code

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:69 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 16:56:15 (2 occurrences) Last logged: 16:57:44

kia_uvo - Exception in update : 'msopServiceOdometerUnit' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 150, in get_cached_vehicle_status if response["msopServiceOdometerUnit"] is not None: KeyError: 'msopServiceOdometerUnit'

cdnninja commented 2 years ago

@simille83 could you open a new issue? These don't appear related.

@olivierjag2 I think I had poor python. I have updated the pull again. Please give that a go.

olivierjag2 commented 2 years ago

ok It works but I have only 3 enties xxxx Data binary_sensor.xxx_data Kia Uvo / Hyundai Bluelink

xxx Last Update sensor.xxx_last_update Kia Uvo / Hyundai Bluelink

xxx Location device_tracker.xxx_location Kia Uvo / Hyundai Bluelink

olivierjag2 commented 2 years ago

in binary I have this

vehicle_data: {} vehicle_name: xxx friendly_name: xxx Data

olivierjag2 commented 2 years ago

File "/config/custom_components/dewpoint/sensor.py", line 166, in async_update dry_temp = self.get_dry_temp(self._entity_dry_temp) File "/config/custom_components/dewpoint/sensor.py", line 109, in get_dry_temp _LOGGER.error('Unable to read temperature from unavailable sensor: %s', state.entity_id) AttributeError: 'NoneType' object has no attribute 'entity_id' 2021-11-19 17:10:04 DEBUG (SyncWorker_2) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Received forced vehicle data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20211119221003', 'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '01H', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 416.0, 'unit': 1}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 81, 'batState': 0, 'sjbDeliveryMode': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineOilStatus': False, 'vehicleMovementHis': False, 'engineRuntime': {'value': 0, 'unit': 1}}}} 2021-11-19 17:10:09 DEBUG (SyncWorker_8) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20211119145414', 'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '01H', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 416.0, 'unit': 1}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 81, 'batState': 0, 'sjbDeliveryMode': 0, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'sleepModeCheck': True, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineOilStatus': False, 'vehicleMovementHis': True, 'engineRuntime': {'value': 29, 'unit': 1}}}} 2021-11-19 17:10:15 DEBUG (SyncWorker_8) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'mtspServiceDate': '20210917', 'imatServiceOdometer': 6000.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20220317', 'currentOdometer': 2225.0, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 6000.0, 'serviceDaysDuration': 181, 'serviceMonthsThreshold': 6}}} 2021-11-19 17:10:15 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'msopServiceOdometerUnit' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 150, in get_cached_vehicle_status if response["msopServiceOdometerUnit"] is not None: KeyError: 'msopServiceOdometerUnit'

cdnninja commented 2 years ago

Error looks like the file hasn't changed. Copy this whole contents and replace the contents of the ApiCA file followed by a restart of home assistant:

https://raw.githubusercontent.com/fuatakgun/kia_uvo/bf1c68bb5b5b1304f1e9e4c9059bd3c16d165c15/custom_components/kia_uvo/KiaUvoApiCA.py

olivierjag2 commented 2 years ago

done, 3 enties again

cdnninja commented 2 years ago

You are only seeing 3 entities? Did this ever work for you? Which ones are showing? Any errors in the logs?

olivierjag2 commented 2 years ago

I load my kia Niro and I have around 30 entities

olivierjag2 commented 2 years ago
original_icon=entity.icon,

File "/config/custom_components/kia_uvo/lock.py", line 40, in icon return "mdi:lock" if self.is_locked else "mdi:lock-open-variant" File "/config/custom_components/kia_uvo/lock.py", line 36, in is_locked return self.vehicle.vehicle_data["vehicleStatus"]["doorLock"] KeyError: 'vehicleStatus'

cdnninja commented 2 years ago

So to be clear the error from before related to msopServiceOdometerUnit is gone?

olivierjag2 commented 2 years ago

yes

olivierjag2 commented 2 years ago

now I don't have entities (exemple Lock, motor etc...)

olivierjag2 commented 2 years ago

I have this error in my log 2021-11-19 17:23:47 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'msopServiceOdometer' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 57, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 146, in get_cached_vehicle_status if response["msopServiceOdometer"]: KeyError: 'msopServiceOdometer'

2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:odometer.value 2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:lastService.value 2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:nextService.value 2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:vehicleLocation.geocodedLocation.display_name 2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:vehicleStatus.battery.batSoc 2021-11-19 17:23:47 DEBUG (MainThread) [custom_components.kia_uvo.sensor] skipping sensor for missing data, key:vehicleStatus.airTemp.value

olivierjag2 commented 2 years ago

line 146 is

Handles cars that have never had service

    if response["msopServiceOdometer"]:
        vehicle_status["lastService"] = {}
        vehicle_status["lastService"]["unit"] = response["msopServiceOdometerUnit"]
        vehicle_status["lastService"]["value"] = response["msopServiceOdometer"]
cdnninja commented 2 years ago

Thank you. Try swap line 146 to:

if response.get("msopServiceOdometerUnit"):

olivierjag2 commented 2 years ago

yes! Working! I Have 26 entities

cdnninja commented 2 years ago

Awesome. I will merge this code it should be in the next release this weekend.

olivierjag2 commented 2 years ago

thx you! last thing I cannot change the : Blackout Start Hour - (No Force Scan), I try to put at 22 but back to 13 do you have idea or change manually in the setting?

cdnninja commented 2 years ago

I have opened 166 to track this new issue you have found.

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 1.1.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: