bimmerconnected / bimmer_connected

🚘 Library to query the status of your BMW or Mini from the ConnectedDrive portal
Apache License 2.0
362 stars 79 forks source link

TypeError: 'NoneType' object is not subscriptable #399

Closed licheng5625 closed 2 years ago

licheng5625 commented 2 years ago

Describe the issue

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 511, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 363, in state value = self.native_value File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/sensor.py", line 173, in native_value return cast(StateType, self.entity_description.value(state, self.hass)) File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/sensor.py", line 91, in hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])) TypeError: 'NoneType' object is not subscriptable

Expected behavior

no error ?

Which Home Assistant version are you using?

Home Assistant 2021.12.8

What was the last working version of Home Assistant Core?

No response

What is your region?

Rest of world

ConnectedDrive website

Number of cars

Output of bimmer_connected fingerprint

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

rikroe commented 2 years ago

Thanks for reporting! Seems like that if an attribute with a unit (e.g. remaining_range) cannot be parsed, we just return None but Home Assistant expects a tuple (e.g. (None, None). Should be an easy fix.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.