G-Two / homeassistant-subaru

Subaru STARLINK custom component for Home Assistant.
Apache License 2.0
54 stars 7 forks source link

Integration failed to setup #101

Closed giantsfan006 closed 10 months ago

giantsfan006 commented 10 months ago

Having some issues with the integration. Usually a reload fixes it but this time it didn't. Component was out-of date so I tried updating but the UI just says "Failed to set up" (logs below). I've also tried restarting HA, uninstalling and reinstalling the integration and HACS component, and downgrading.

Any help would be appreciated.

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/subaru/__init__.py:218
Integration: Subaru (HACS) (documentation, issues)
First occurred: 12:13:25 PM (2 occurrences)
Last logged: 12:15:05 PM

Error setting up entry [emailredacted]@gmail.com for subaru
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/subaru/__init__.py", line 103, in async_setup_entry
    vehicles[vin] = await _get_vehicle_info(controller, vin)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/subaru/__init__.py", line 218, in _get_vehicle_info
    VEHICLE_HAS_POWER_WINDOWS: await controller.has_power_windows(vin),
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 286, in has_power_windows
    await self.get_data(vin)
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 409, in get_data
    await self.fetch(vin)
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 569, in fetch
    result = await self._fetch_status(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 1070, in _fetch_status
    status = await self._parse_condition(js_resp, vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 1304, in _parse_condition
    keep_data[sc.TIMESTAMP] = datetime.strptime(data[api.API_LAST_UPDATED_DATE], api.API_TIMESTAMP_FMT)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2023-11-09T20:10:22.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'
JPorter-02 commented 10 months ago

I was also getting this error upon re-installing the integration for some troubleshooting. Thankfully i restored from a backup and it works now, but vehicle statistics such as tire pressure are not loading. Remote start, lock and unlock still work. It seems the prominent error is:

Unexpected error fetching subaru_data data: time data '2023-11-09T20:09:25.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'

Mark612 commented 10 months ago

Yes, same problem. It is intermittent. Sometimes will load and work.

Mark612 commented 10 months ago

I hacked the code to fix the error. "ValueError: time data '2023-11-09T20:10:22.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'"

Seems to be working.

subarulink/_subaru_api/const.py

Changed to:

API_TIMESTAMP_FMT = "%Y-%m-%dT%H:%M:%S.000%z" # "2020-04-25T23:35:55.000+0000"

giantsfan006 commented 10 months ago

I hacked the code to fix the error. "ValueError: time data '2023-11-09T20:10:22.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'"

Seems to be working.

subarulink/_subaru_api/const.py

Changed to:

API_TIMESTAMP_FMT = "%Y-%m-%dT%H:%M:%S.000%z" # "2020-04-25T23:35:55.000+0000"

I don't see API_TIMESTAMP_FMT in the const.py. Did you simply add it in? Bc that didn't seem to work for me

G-Two commented 10 months ago

Issue should be fixed now with 0.7.12

giantsfan006 commented 10 months ago

Issue should be fixed now with 0.7.12

Awesome! Thanks for resolving so quickly!