skodaconnect / homeassistant-myskoda

Homeassistant integration for MySkoda.
97 stars 15 forks source link

Position still crashing integration #54

Closed Prior99 closed 1 month ago

Prior99 commented 2 months ago

An unavailable position still crashes the integration:

2024-09-29 16:56:50.125 ERROR (MainThread) [custom_components.myskoda.coordinator] Unexpected exception from <bound method MySkodaDataUpdateCoordinator._update_vehicle of <custom_components.myskoda.coordinator.MySkodaDataUpdateCoordinator object at 0x7f9789511fa0>>
Traceback (most recent call last):
  File "/config/custom_components/myskoda/coordinator.py", line 183, in _update_vehicle
    self.set_updated_vehicle(vehicle)
  File "/config/custom_components/myskoda/coordinator.py", line 157, in set_updated_vehicle
    self.async_set_updated_data(self.data)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 489, in async_set_updated_data
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 533, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 238, in state
    if self.latitude is not None and self.longitude is not None:
       ^^^^^^^^^^^^^
  File "/config/custom_components/myskoda/device_tracker.py", line 66, in latitude
    position = self._vehicle_position()
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/myskoda/device_tracker.py", line 54, in _vehicle_position
    return next(
           ^^^^^
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 137, in _handle_timer_finish
    await task
RuntimeError: coroutine raised StopIteration
WebSpider commented 2 months ago

Yeah, #24 was reopened for this

WebSpider commented 2 months ago

@dvx76 was able to fetch an API response covering this. I'll develop a PR based on it.