home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.63k stars 29.93k forks source link

python_script returns "async_get_hass called from the wrong thread" when calling a service #122810

Open mikz opened 1 month ago

mikz commented 1 month ago

The problem

A primitive python script with the following content:

hass.services.call('logbook', 'log', {'name': 'test', 'message': 'message'})

And it fails even with different variations of blocking=True, return_response=False, blocking=False, return_response=False, ...

Throws an error when called: async_get_hass called from the wrong thread

What version of Home Assistant Core has the issue?

core-2024.7.3

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

python_script

Link to integration documentation on our website

https://www.home-assistant.io/integrations/python_script

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

python_script documentation python_script source