Error when pressing wake button with automation action
The problem
I'm getting an error when using automation action to press the car wake button. Manually pressing the button doesn't produce an error.
Error code: 'NoneType' object has no attribute 'get'. Please see in detail below.
What version of Home Assistant Core has the issue?
2024.10.0 and 2024.10.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Tesla Fleet
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tesla_fleet
Diagnostics information
No response
Example YAML snippet
action: button.press
target:
entity_id: button.tesla_wake
data: {}
Anything in the logs that might be useful for us?
2024-10-04 23:06:39.349 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
await self.async_press()
File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/button.py", line 97, in async_press
await handle_vehicle_command(self.entity_description.func(self))
File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/helpers.py", line 53, in handle_vehicle_command
if (response := result.get("response")) is None:
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
2024-10-04 23:06:39.355 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140603109305664] Error handling message: Unknown error (unknown_error) **REDACTED**
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 580, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
await self.async_press()
File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/button.py", line 97, in async_press
await handle_vehicle_command(self.entity_description.func(self))
File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/helpers.py", line 53, in handle_vehicle_command
if (response := result.get("response")) is None:
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Additional information
No response
Hey there @bre77, mind taking a look at this issue as it has been labeled with an integration (tesla_fleet) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of tesla_fleet can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign tesla_fleetRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
tesla_fleet documentation tesla_fleet source (message by IssueLinks)
I suspect I know exactly what's wrong here. Ill get a PR raised to fix it.
As an FYI you shouldn't need to call wakeup in automations, unless you're doing it on home Assistant start-up. All commands will call wake up themselves if your vehicle is asleep.
I see this on wake as well, but my MY requires command signing, so I can't really do any actions anyway. Happy to help test also.
Thanks for all your work on this. Really pumped to see all the additional platforms show up in 2024.10!
I suspect I know exactly what's wrong here. Ill get a PR raised to fix it.
As an FYI you shouldn't need to call wakeup in automations, unless you're doing it on home Assistant start-up. All commands will call wake up themselves if your vehicle is asleep.
Thanks! And yes, I'm waking the car when ha core is shutting down so when the restart completes the sensors doesn't give erroneous values. Now that you mentioned it, would it be possible to make the sensors return the previous value after core restart (i.e. when Tesla Fleet integration is loaded) even if the car is sleeping?
Thanks! That fixed it for me.
would it be possible to make the sensors return the previous value after core restart (i.e. when Tesla Fleet integration is loaded) even if the car is sleeping?
Its meant to already be doing this for most sensors, as I am using the Home Assistant restore feature.