I’m trying to use the wait_state function in one of my callbacks, however, when the wait state is fulfilled, I keep getting an index error in the logs.
For some background the callback waits for the value of an input_boolean
to change to “on”.
Here is the callback definition:
async def vehicle_in(self, data, *args, **kwargs):
try:
await self.vehicle_detected.wait_state("on", timeout=300)
except:
return None
self.garage_door.call_service("open_cover")
I tried moving self.garage_door.call_service("open_cover")
to inside the ‘try’ statement but I got the same issue:
2023-08-01 15:11:04.829009 WARNING auto_garage: ------------------------------------------------------------
2023-08-01 15:11:04.829381 WARNING auto_garage: Unexpected error in worker for App auto_garage:
2023-08-01 15:11:04.829756 WARNING auto_garage: Worker Ags: {'id': 'f4308dcdfb4a43b0b160959e4295d0f1', 'name': 'auto_garage', 'objectid': '21a22b33ebc5475991f4c1acef5ac695', 'type': 'state', 'function': <bound method Entity.entity_state_changed of input_boolean.vehicle_detected>, 'attribute': 'state', 'entity': 'input_boolean.vehicle_detected', 'new_state': 'on', 'old_state': 'off', 'pin_app': True, 'pin_thread': 0, 'kwargs': {'__entity': 'input_boolean.vehicle_detected', '__attribute': 'state', '__old_state': 'off', '__new_state': 'on', 'new': 'on', 'attribute': None, 'duration': 0, 'immediate': True, 'oneshot': True, '__silent': True, 'wait_id': '3f032d988a6540c2aa57876ee8343247', '__handle': '33033c48606b44a2a1d7b516a72538bb', '__thread_id': 'MainThread'}}
2023-08-01 15:11:04.830037 WARNING auto_garage: ------------------------------------------------------------
2023-08-01 15:11:04.832584 WARNING auto_garage: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 908, in async_worker
await funcref(
File "/usr/lib/python3.11/site-packages/appdaemon/entity.py", line 426, in entity_state_changed
wait_id = args[4]["wait_id"]
~~~~^^^
IndexError: tuple index out of range
2023-08-01 15:11:04.833114 WARNING auto_garage: ------------------------------------------------------------
Does anyone know if this is an AppDaemon issue (I couldn’t find anything in known issues for the repo) or if I’m doing something wrong?