alandtse/tesla

KeyError: 'vehicle_state'

Closed

#555 opened on Mar 27, 2023

 (1 comment) (0 reactions) (0 assignees)Python (128 forks)github user discovery
buggood first issuehelp wanted

Repository metrics

Stars
 (777 stars)
PR merge metrics
 (Avg merge 13d 8h) (14 merged PRs in 30d)

Description

Version of the custom_component

3.10.4 (latest)

Configuration

2023-03-26 20:30:17.498 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 65 Interval 60
2023-03-26 20:30:17.498 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:05:36
2023-03-26 20:30:17.498 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles {}
2023-03-26 20:30:17.682 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":1493058754918886,"vehicle_id":264948359911,"vin":"5YJ3E1EC1NF129414","display_name":"Federico's electric super car","option_codes":null,"color":null,"access_type":"OWNER","tokens":["01974e21d2344228","a002b95a519d94b9"],"state":"online","in_service":false,"id_s":"1493058754918886","calendar_enabled":true,"api_version":52,"backseat_token":null,"backseat_token_updated_at":null,"ble_autopair_enrolled":false}],"count":1}
2023-03-26 20:30:17.683 DEBUG (MainThread) [teslajsonpy.controller] 29414: online. Polling policy: normal. Update state: normal. Since last park: 8300.272000074387. Since last wake up: 20182. Idle interval: 600. shift_state: None sentry: True climate: False, charging: Disconnected 
2023-03-26 20:30:17.683 DEBUG (MainThread) [teslajsonpy.controller] 29414: Skipping update with state online. Polling: True. Last update: 293 ago. Last parked: 8299.272000074387 ago. Last wake up 20181 ago. 
2023-03-26 20:30:17.683 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 184280630899
2023-03-26 20:30:17.683 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:05:36
2023-03-26 20:30:17.684 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/184280630899/live_status {}
2023-03-26 20:30:17.946 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":0,"grid_status":"Unknown","grid_services_active":false,"timestamp":"2023-03-26T20:30:17-07:00","wall_connectors":null}}

Describe the bug

There is a key error when looking up a dictionary in the lock.unlock Service call

Debug log


2023-03-26 12:54:22.027 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall lock.unlock (c:01GWFQQXMK8RWZKWAZGZ7ZPA4M): entity_id=['lock.federico_s_electric_super_car_doors']>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1826, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 726, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 106, in _async_unlock
    await entity.async_unlock(**remove_entity_service_fields(service_call))
  File "/config/custom_components/tesla_custom/lock.py", line 50, in async_unlock
    await self._car.unlock()
  File "/usr/local/lib/python3.10/site-packages/teslajsonpy/car.py", line 1138, in unlock
    self._vehicle_data["vehicle_state"].update(params)
KeyError: 'vehicle_state'


Contributor guide