Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for HA 2024.9 #263

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fixes for HA 2024.9 #263

wants to merge 4 commits into from

Conversation

michalmo
Copy link

The PR adds fixes to get this custom component working with Home Assistant 2024.9 (tested with 2024.91. and 2024.9.2)
Specifically it fixes issues #258 and #261 and bumps the required version.

Copy link

@jjrytko jjrytko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested these changes locally, everything seems to work. Thank you :)

@Nukle0n
Copy link

Nukle0n commented Sep 19, 2024

Also tested these by swapping out the files and restarting zha-toolkit and it works again now.

@CordoWEB
Copy link

All seems to be ok with this patch.
Works fine on HA 2024.9.2.
Thanks a lot.

@michalmo
Copy link
Author

Hey @mdeweerd, can you find some time to review this? From the reactions it looks like there are a few people waiting on these fixes.

@thewolf-oz
Copy link

Have just tested these files and working for me on 2024.10.0

@Rudd-O
Copy link

Rudd-O commented Oct 5, 2024

Can this please be merged ASAP?

@papylhomme
Copy link

Tested and working for 2024.10.2

@jetmcquack
Copy link

@mdeweerd hello can you please merge this? There’s a lot of people awaiting this PR.

@raspberryvincent
Copy link

Has anyone found another solution ?

@EiNSTeiN-
Copy link

I forked this repo and applied the fixes for myself, this works for my own use until this issue is fixed upstream. Anyone else is welcome to use my fork at https://github.com/EiNSTeiN-/zha-toolkit but be aware I'm not going to keep up with upstream so you may be missing new versions until this is resolved.

To use the fork, go to HACS and uninstall zha-toolkit, then add a custom repository and put in https://github.com/EiNSTeiN-/zha-toolkit as URL, then install the new zha-toolkit which will appear in the list. My version will have (fork) at the end of the name.

@raspberryvincent
Copy link

Thanks it's work for me with the fork. 👍🏻

@joshua-lehmann
Copy link

I had the same error initially and then installed the fork from @EiNSTeiN-
However, even with that the Scan Device action always fails but this time with a different error. Anyone has an idea? And @michalmo would your PR also fix that, or you think it is not related?

[140735235457232] Error handling message: Unknown error (unknown_error) Joshua from 192.168.178.57 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36)
[140733472884480] Error handling message: Unknown error (unknown_error) Joshua from 192.168.178.57 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 832, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 784, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 898, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/default.py", line 51, in default
    await handler(app, listener, ieee, cmd, data, service, params, event_data)
  File "/config/custom_components/zha_toolkit/scan_device.py", line 462, in scan_device
    scan = await scan_results(
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/scan_device.py", line 83, in scan_results
    await scan_endpoint(ep, manufacturer, tries=tries)
  File "/config/custom_components/zha_toolkit/scan_device.py", line 112, in scan_endpoint
    clusters[key] = await scan_cluster(
                    ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/scan_device.py", line 139, in scan_cluster
    attributes = await discover_attributes_extended(cluster, None, tries=tries)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/scan_device.py", line 236, in discover_attributes_extended
    attr_type.type_class.__name__,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DataClass' object has no attribute '__name__'. Did you mean: '__hash__'?

@michalmo
Copy link
Author

@joshua-lehmann looks like a bug introduced by my PR (an incorrect application of what I was fixing), I'll update the PR later when I have a moment, and ask you to test it.

@claudegel
Copy link

claudegel commented Oct 30, 2024

Look like a fix is to replace line 236 in scan_device.py
attr_type.type_class.__name__,
by
attr_type.type_class.name,
It work for me

@michalmo
Copy link
Author

Just checked and i've come to the conclusion that @claudegel's fix is correct. I've updated the PR.
@EiNSTeiN- you may want to update your fork for the people that have installed it.

@joshua-lehmann
Copy link

@claudegel I used your suggested change, and it fixed the error, thank you! @michalmo I can confirm that the fix he did worked and solved the issue so your fix should work as well. What is the ETA of merging this into the official repo? I saw its open for a longer time already.

@michalmo
Copy link
Author

I don't know 🤷. @mdeweerd has been unresponsive for a while.

@samuel9554
Copy link

@mdeweerd Could you approve this and push it into a release? Thank you!

@martetassyns
Copy link

This also fixed my issues, hoping for an official review/release soon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.