jnxxx / homeassistant-connectedcars_io

Home Assistant integration for connectedcars.io (Min Volkswagen)
17 stars 2 forks source link

Refueling events / parsing failing? #17

Closed mm98 closed 11 months ago

mm98 commented 12 months ago

Hi,

It looks like there still are some kind of bug(s) with the refueling event from ConnectedCars. Strangely it worked last time I refueled with the same version of the integration (v1.1.1).

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:696
First occurred: 10:31:13 (5 occurrences)
Last logged: 10:35:13

Update for sensor.audi_a5_mileage_since_refuel fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 696, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 957, in async_device_update
    await self.async_update()
  File "/config/custom_components/connectedcars_io/sensor.py", line 385, in async_update
    distance_since_refuel = odometer_current - self._dict["Odometer"]
                            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

https://github.com/jnxxx/homeassistant-connectedcars_io/blob/3f4f010a508cd308b10feeafa1cdf9a1371dc3ce/custom_components/connectedcars_io/sensor.py#L381-L387


This error originated from a custom integration.

Logger: custom_components.connectedcars_io.device_tracker
Source: custom_components/connectedcars_io/device_tracker.py:171
Integration: Connectedcars.io (Min Volkswagen) (documentation, issues)
First occurred: 10:31:13 (5 occurrences)
Last logged: 10:35:13

Unable to parse ignition timestamp. Err: Invalid isoformat string: 'None'

https://github.com/jnxxx/homeassistant-connectedcars_io/blob/3f4f010a508cd308b10feeafa1cdf9a1371dc3ce/custom_components/connectedcars_io/device_tracker.py#L162-L172 Note: audi_a5_fuel_economy is disabled as suggested in #15.

jnxxx commented 12 months ago

I do not get these two errors myself, but I can see how it can lead to such loggings if the read values are null. I have now added some more error handling. Try the version in the main branch (not in a release yet).

  1. Mileage since refuel: It now checks for odometer_current being null / None, and if so does not do the calculation. Instead the sensor should show as unavailable, until the odometer reports a value again.

  2. Location: It only updates location when ignition is on, or last ignition timestamp has changed. This is to avoid triggering automations due to GPS inaccuracy. If the ignition timestamp is not reported or is invalid, it will now just update the location even when ignition is off.

  3. From #15 the rounding is now done by Home Assistant. Mine has started to report a value again, but if it ever reports null again, HA should just show it as unavailable.

mm98 commented 12 months ago

Try the version in the main branch (not in a release yet).

Thanks! I'll give it a try and report back with any findings.

mm98 commented 11 months ago

Hi. The changes in the main branch removed the errors. So I guess this can be closed?

jnxxx commented 11 months ago

Yes, let's close it.

Fixes have now been released in v1.1.2.