ZHA toolkit -service call broken?

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.

Perhaps there are other ZHA related issues in this release ?

Also, I now have a new ZHA related error popped up that I’ve never seen before:

Log Details (ERROR)
Logger: homeassistant.helpers.integration_platform
Source: helpers/integration_platform.py:61
First occurred: 19:13:23 (1 occurrences)
Last logged: 19:13:23

Error processing platform zha.repairs
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/integration_platform.py", line 61, in _async_process_single_integration_platform_component
    await integration_platform.process_platform(hass, component_name, platform)
  File "/usr/src/homeassistant/homeassistant/components/repairs/issue_handler.py", line 113, in _register_repairs_platform
    raise HomeAssistantError(f"Invalid repairs platform {platform}")
homeassistant.exceptions.HomeAssistantError: Invalid repairs platform <module 'homeassistant.components.zha.repairs' from '/usr/src/homeassistant/homeassistant/components/zha/repairs.py'>

2023.10.0 introduced an incompatibility with zha-toolkit - hopefully that’s fixed in v1.1.2 .

You can try it yourself by enabling beta in the repository and selecting 1.1.2 then redownload.

Exceptionnally, to fix the 2023.10.X compatibility, a HA restart is also required (1.1.2 is now officially release as a user confirmed it works on 2023.10.0).