bimmerconnected / bimmer_connected

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

Get an error when update the vehicle status in homeassistant #373

Closed muxiachuixue closed 2 years ago

muxiachuixue commented 2 years ago

Describe the issue

Sometimes (not every time) when I call the service "bmw_connected_drive.update_state" in homeassistant, it gives me an error: See below.

A restart of HA can solve this problem.

Bimmerconnected version in HA: 0.8.3.0b4

Operating_system: Raspbian GNU/Linux 10 (buster)

Expected behavior

When I call the homeassistant service "bmw_connected_drive.update_state" , it returns no error.

Which Home Assistant version are you using?

2021.11.5

What was the last working version of Home Assistant Core?

No response

What is your region?

China

ConnectedDrive website

Number of cars

Output of bimmer_connected fingerprint

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/bmw_connected_drive/__init__.py:319
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 11:46:23 (4 occurrences)
Last logged: 11:50:06

[2718049568] 'status'
[2718049568] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/config/custom_components/bmw_connected_drive/__init__.py", line 132, in _async_update_all
    await hass.async_add_executor_job(_update_all)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bmw_connected_drive/__init__.py", line 137, in _update_all
    entry[CONF_ACCOUNT].update()
  File "/config/custom_components/bmw_connected_drive/__init__.py", line 319, in update
    self.account.update_vehicle_states()
  File "/usr/local/lib/python3.9/site-packages/bimmer_connected/account.py", line 412, in update_vehicle_states
    self._get_vehicles()
  File "/usr/local/lib/python3.9/site-packages/bimmer_connected/account.py", line 390, in _get_vehicles
    existing_vehicle.update_state(vehicle_dict)
  File "/usr/local/lib/python3.9/site-packages/bimmer_connected/vehicle.py", line 91, in update_state
    self.status.update_state({k: v for k, v in vehicle_dict.items() if k in [SERVICE_STATUS, SERVICE_PROPERTIES]})
  File "/usr/local/lib/python3.9/site-packages/bimmer_connected/vehicle_status.py", line 166, in update_state
    self.status: Dict = status_dict["status"]
KeyError: 'status'

Additional information

No response

rikroe commented 2 years ago

Thanks for reporting! I'll will try to catch this information and print some error logs.

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.