CJNE / ha-porscheconnect

Porsche Connect custom component for Home Assistant
MIT License
31 stars 14 forks source link

ERROR (MainThread) [custom_components.porscheconnect] Unexpected error fetching porscheconnect data #242

Open barto64 opened 5 months ago

barto64 commented 5 months ago

Version of the custom_component

0.0.18

Configuration


Add your logs here.
``2024-06-12 12:33:55.372 ERROR (MainThread) [custom_components.porscheconnect] Unexpected error fetching porscheconnect data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/porscheconnect/__init__.py", line 211, in _async_update_data
    summary = await self.controller.getSummary(vin)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyporscheconnectapi/client.py", line 484, in getSummary
    data = await self._connection.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyporscheconnectapi/connection.py", line 304, in get
    return await resp.json()
           ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 79, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1192, in json
    return loads(stripped.decode(encoding))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 48, in json_loads
    return orjson.loads(__obj)  # type:ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)`

## Describe the bug

Integration does not work, device and entities not available.

## Debug log

<!-- To enable debug logs check this https://www.home-assistant.io/components/logger/ -->

```text

Add your logs here.
Jimnaldo commented 1 week ago

@barto64 or others, is the data being updated for you? For me it seems to only update when i manually reload the integration.

I notice the same behaviour

barto64 commented 1 week ago

@Jimnaldo , @royalidea I have been running the component on my DEV instance in DEBUG and i could see every 32 min and update being executed.

@fredriklj not sure what is he whish list you refer to. I like very much the sensors and switches the old component provided before Porsche made the changes. So, anything similiar to that would be great. For me personally it was great the ability to execute the Direct Charge as I used to combine different parameters from my solar pannels and home power consumption to force the car charge.

royalidea commented 1 week ago

@Jimnaldo , @royalidea I have been running the component on my DEV instance in DEBUG and i could see every 32 min and update being executed.

@fredriklj not sure what is he whish list you refer to. I like very much the sensors and switches the old component provided before Porsche made the changes. So, anything similiar to that would be great. For me personally it was great the ability to execute the Direct Charge as I used to combine different parameters from my solar pannels and home power consumption to force the car charge.

@barto64 but are the values also updated in the json you see in the logs? Because for me it's always the same until i reload the integration.

barto64 commented 1 week ago

@royalidea , honestly i am not able to say whether they are updated, i am not using the car so mileage or battery level which would be the easier one to change in my case will not do it. Enable the DEBUG and you will see the payload the integration receives from the Porsche Servers. If you see the value changing in the payload and not in the integration it would be for our friend @fredriklj to fix, but that would be really weird. You can also validate Payload values, integration values and mobile app value to identify potential differences. I see many times my App not updating the info either.

fredriklj commented 1 week ago

@barto64 or others, is the data being updated for you? For me it seems to only update when i manually reload the integration.

I see it too. Will have a look at it.

fredriklj commented 1 week ago

@fredriklj not sure what is he whish list you refer to. I like very much the sensors and switches the old component provided before Porsche made the changes. So, anything similiar to that would be great. For me personally it was great the ability to execute the Direct Charge as I used to combine different parameters from my solar pannels and home power consumption to force the car charge.

Switches for climatisation and direct charge, as well a control of the lock is on my to-do list. Maybe also honk & flash.

I am happy to receive feature requests for any other sensors or services.

fredriklj commented 1 week ago

@royalidea Obviously I had a brain fart. Please update and install pyporscheconnect again, updates should work now.

Jimnaldo commented 1 week ago

@fredriklj now i get this error, please advise?:

Log details (ERROR) This error originated from a custom integration. Logger: custom_components.porscheconnect Source: helpers/update_coordinator.py:382 integration: Porsche Connect (documentation, issues) First occurred: 4:03:05 PM (4 occurrences) Last logged: 4:03:44 PM

Unexpected error fetching porscheconnect data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/porscheconnect/init.py", line 132, in _async_update_data self.vehicles = await self.controller.get_vehicles() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyporscheconnectapi/account.py", line 58, in get_vehicles await self._init_vehicles() File "/usr/local/lib/python3.12/site-packages/pyporscheconnectapi/account.py", line 47, in _init_vehicles await v._update_data_for_vehicle() File "/usr/local/lib/python3.12/site-packages/pyporscheconnectapi/vehicle.py", line 127, in _update_data_for_vehicle mdata["CHARGING_SUMMARY"]["chargingProfile"][


KeyError: 'chargingProfile'
barto64 commented 1 week ago

Yep, I have the same error, there seem to be a mistmatch in between the API and the component.

fredriklj commented 1 week ago

@Jimnaldo @barto64 What kind of cars do you have? ICE or BEV or Hybrid? Can you post me the data object of the vehicle? (Got measurement data for vehicle ..)

barto64 commented 1 week ago

Mine is Hybrid and cannot provide a fresh data object as my integration is now broken. I guess you mean the JSON Porsche server return with all data for the car. This is the latest i have Porsche Payload 1.json

fredriklj commented 1 week ago

Ok, got it! Fixed in last commit of pyporscheconnectapi. Please try and see if it resolves it.

barto64 commented 1 week ago

It went back to live. I uninstall the API and installed it again, deleted the pycache dir, reboot the HA and it worked.

FYI, I am about to leave mid day tomorrow for a couple of week and will not be able to assist during that time.

fredriklj commented 22 hours ago

Folks, we are about to make a new release of the ha component any day now. But we need testers with different types of cars and also I know some of you have more than one, which would be of great value to know how/if that works.

So if you can, please check out the new_api branch and make sure to have the same branch of the pyporcheconnectapi installed and updated to the last commit. Bugs can be reported as new issues, not to clutter this thread even more.

Thanks!

jfrigger commented 21 hours ago

I have latest (Build Date 07/2024) Cayenne hybrid. Will it help ?

fredriklj commented 5 hours ago

@jfrigger All testing would help, absolutely! Any types of nits and grits that can be spotted. Bugs of course, but also unavailable sensors, missing information, awkward translations, etc.

f1dgj commented 3 hours ago

I have a 2023 Taycan Turbo that I could test with Sent from my iPhoneOn 24 Nov 2024, at 10:16, Fredrik Ljunggren @.***> wrote: @jfrigger All testing would help, absolutely! Any types of nits and grits that can be spotted. Bugs of course, but also unavailable sensors, missing information, awkward translations, etc.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>