Not sure when it broke, but I have a script that runs on an hourly basis to check if my ZHA devices are online.
Its powered by this service call:
- service: zha_toolkit.zha_devices
data:
event_done: zha_devices_ready
Which now returns this error when run in the dev tools :-
Failed to call service zha_toolkit.zha_devices. Unknown error
Any thoughts on how to get this working again ?
@le_top - you were super helpful originally getting this working for me.
The full existing script is below:
alias: Check for ZHA offline devices and notify
sequence:
- parallel:
- - wait_for_trigger:
- platform: event
event_type: zha_devices_ready
- repeat:
for_each: "{{ wait.trigger.event.data.devices }}"
sequence:
- if:
- condition: template
value_template: >
{{ (repeat.item.available | bool() == false) and ((('IKEA
of Sweden TRADFRI on/off switch' not in repeat.item.name)
and ('IKEA of Sweden Remote Control N2' not in
repeat.item.name) and ('_NOT-USED' not in
repeat.item.name)))}}
then:
- service: notify.mobile_app_rofo_phone
data:
title: Device Offline
message: >-
{{ "(%s) LQI: %s" % ( repeat.item.user_given_name,
repeat.item.lqi ) }}
- service: zha_toolkit.zha_devices
data:
event_done: zha_devices_ready
mode: single
There is also this error in the logs:
websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'ZHAData' object is not subscriptable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/zha_toolkit/__init__.py", line 672, in toolkit_service
zha_gw = hass_ref.data["zha"]["zha_gateway"]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
TypeError: 'ZHAData' object is not subscriptable
I think this error has only started appearing since I upgraded to Home Assistant 2023.10.0 today.