Skip to content

Error when parsing time in controller.py #96

@anoopknayak

Description

@anoopknayak

Hi,

I have been running subaru integration in Home assistant but I see the following error in the logs:

Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/components/subaru/__init__.py", line 75, in async_update_data
    return await refresh_subaru_data(entry, vehicle_info, controller)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/components/subaru/__init__.py", line 125, in refresh_subaru_data
    await controller.fetch(vin, force=True)
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/subarulink/controller.py", line 569, in fetch
    result = await self._fetch_status(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/subarulink/controller.py", line 1070, in _fetch_status
    status = await self._parse_condition(js_resp, vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/deps/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 "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-02-04T18:53:51.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'

I can submit a patch if I get time, but I believe the right fix would be to iterate through all the known time formats obtained from subaru. Wdyt @G-Two?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions