Describe the bug
Running service.toggle(entity_id="switch.sonoff_basic_relay") have an error.
To Reproduce
from homeassistant_api import Client
with Client(
'url',
'token'
) as client:
service = client.get_domain("switch")
service.toggle(entity_id="switch.sonoff_basic_relay")
Expected behavior
I expect toggle of switch switch.
Screenshots
Error:
Traceback (most recent call last):
File "/home/user/tests/ha.py", line 10, in <module>
service.toggle(entity_id="switch.sonoff_basic_relay")
File "/home/user/tests/env/lib/python3.10/site-packages/homeassistant_api/models/domains.py", line 115, in __call__
caller := gc.get_referrers(parent_frame.f_code)[0]
IndexError: list index out of range
pip freeze:
aiodns==3.0.0
aiohttp==3.8.1
aiohttp-client-cache==0.6.1
aiosignal==1.2.0
appdirs==1.4.4
async-timeout==4.0.2
attrs==21.4.0
Brotli==1.0.9
cattrs==22.1.0
cchardet==2.1.7
certifi==2022.6.15
cffi==1.15.1
charset-normalizer==2.0.12
exceptiongroup==1.0.0rc8
frozenlist==1.3.0
homeassistant-api==4.0.0
idna==3.3
itsdangerous==2.1.2
multidict==6.0.2
pycares==4.2.1
pycparser==2.21
pydantic==1.9.0
python-forge==18.6.0
requests==2.27.1
requests-cache==0.9.5
simplejson==3.17.6
six==1.16.0
typing_extensions==4.3.0
url-normalize==1.4.3
urllib3==1.26.11
yarl==1.7.2
Desktop (please complete the following information):
-
OS: Archlinux
-
Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
-
Home Assistant 2022.7.7
-
Supervisor 2022.07.0
-
Operating System 8.4
-
Frontend 20220707.1 - latest
Additional context
I removed [0] in the end of line 115 in file models/domains.py to solved this.
108 def __call__(
109 self, **service_data
110 ) -> Union[Tuple[State, ...], Coroutine[Any, Any, Tuple[State, ...]]]:
111 """Triggers the service associated with this object."""
112 assert (frame := inspect.currentframe()) is not None
113 assert (parent_frame := frame.f_back) is not None
114 if inspect.iscoroutinefunction(
115 caller := gc.get_referrers(parent_frame.f_code)
116 ) or inspect.iscoroutine(caller):
117 return self.async_trigger(**service_data)
118 return self.trigger(**service_data)
Describe the bug
Running
service.toggle(entity_id="switch.sonoff_basic_relay")have an error.To Reproduce
Expected behavior
I expect toggle of switch switch.
Screenshots
Error:
pip freeze:
Desktop (please complete the following information):
OS: Archlinux
Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
Home Assistant 2022.7.7
Supervisor 2022.07.0
Operating System 8.4
Frontend 20220707.1 - latest
Additional context
I removed
[0]in the end of line 115 in filemodels/domains.pyto solved this.