jampez77 / DVLA-Vehicle-Enquiry-Service

A custom component for connecting to the DVLAs Vehicle Enquiry Service API.
MIT License
22 stars 5 forks source link

Error adding entities for domain calendar with platform dvla #7

Closed markcocker closed 8 months ago

markcocker commented 8 months ago

I am getting the follow error in the log for each vehicle.

Environment

Message in Home Assistant log

Logger: homeassistant.components.calendar
Source: helpers/entity_platform.py:507
Integration: Calendar (documentation, issues)
First occurred: 13:33:21 (2 occurrences)
Last logged: 13:33:21

Error adding entities for domain calendar with platform dvla
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 539, in async_write_ha_state
    super().async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 522, in state
    if (event := self.event) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/dvla/calendar.py", line 95, in event
    events = self.get_events(datetime.today())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dvla/calendar.py", line 102, in get_events
    value = date.fromisoformat(self.coordinator.data.get(date_sensor_type.key))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: fromisoformat: argument must be str
dewet22 commented 8 months ago

@markcocker out of interest, are your vehicles new and still within their 3-year MOT grace period?

jampez77 commented 8 months ago

Thanks for taking the time to create this issue. This has been addressed in 2024.1.0