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

Add update platform to ZHA (bumps zigpy to 0.61.0) #107612

Merged
merged 33 commits into from
Jan 31, 2024

Conversation

dmulcahey
Copy link
Contributor

@dmulcahey dmulcahey commented Jan 8, 2024

Proposed change

This PR adds update entities to ZHA.

REQUIRES: zigpy/zigpy#1321

Zigpy bumped to 0.61.0: https://github.com/zigpy/zigpy/releases/tag/0.61.0

There is still a lot to do here:

  • error handling
  • tests
  • docs PR
  • code cleanup

device-page
dialog
dialog-action
dialog-progress

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Jan 8, 2024

Hey there @Adminiuga, @puddly, @TheJulianJES, mind taking a look at this pull request as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zha Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@dmulcahey
Copy link
Contributor Author

This needs a Zigpy bump for the tests to pass

tests/components/zha/test_update.py Outdated Show resolved Hide resolved
homeassistant/components/zha/update.py Outdated Show resolved Hide resolved
tests/components/zha/test_update.py Outdated Show resolved Hide resolved
@TheJulianJES
Copy link
Member

Probably expected, clicking "check for updates" causes the update checks for sleeping/most battery-powered devices to time out and print an exception about how the message couldn't be delivered.

Do we want to keep this, or like not print the exception in that case, just a simple warning it couldn't be queried?

Home Assistant Logs (click to expand)
2024-01-31 01:53:53.404 WARNING (MainThread) [homeassistant.helpers.entity] Update of update.ikea_of_sweden_tradfri_remote_control_firmware_2 is taking over 10 seconds
2024-01-31 01:53:53.405 WARNING (MainThread) [homeassistant.helpers.entity] Update of update.lumi_lumi_motion_ac02_firmware is taking over 10 seconds
2024-01-31 01:53:53.405 WARNING (MainThread) [homeassistant.helpers.entity] Update of update.lumi_lumi_motion_ac02_firmware_4 is taking over 10 seconds

[...]

2024-01-31 01:54:11.255 ERROR (MainThread) [homeassistant.helpers.entity] Update for update.ikea_of_sweden_tradfri_remote_control_firmware_2 fails
Traceback (most recent call last):
  File "/Users/test/PycharmProjects/HomeAssistantcore/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/Users/test/PycharmProjects/HomeAssistantcore/homeassistant/helpers/entity.py", line 1259, in async_device_update
    await self.async_update()
  File "/Users/test/PycharmProjects/HomeAssistantcore/homeassistant/components/zha/update.py", line 143, in async_update
    await self._ota_cluster_handler.async_check_for_update()
  File "/Users/test/PycharmProjects/HomeAssistantcore/homeassistant/components/zha/core/cluster_handlers/general.py", line 585, in async_check_for_update
    await self.cluster.image_notify(
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 411, in reply
    return await self._endpoint.reply(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/zigpy/endpoint.py", line 278, in reply
    return await self.device.reply(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/zigpy/device.py", line 488, in reply
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/zigpy/device.py", line 322, in request
    await send_request()
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/zigpy/application.py", line 833, in request
    await self.send_packet(
  File "/Users/test/PycharmProjects/HomeAssistantcore/venv/lib/python3.11/site-packages/bellows/zigbee/application.py", line 931, in send_packet
    raise zigpy.exceptions.DeliveryError(
zigpy.exceptions.DeliveryError: Failed to deliver message: <EmberStatus.DELIVERY_FAILED: 102>

@dmulcahey
Copy link
Contributor Author

Probably expected, clicking "check for updates" causes the update checks for sleeping/most battery-powered devices to time out and print an exception about how the message couldn't be delivered.

Do we want to keep this, or like not print the exception in that case, just a simple warning it couldn't be queried?

Home Assistant Logs (click to expand)

That’s expected. If you wanna update a battery device it needs to be woken up.

@dmulcahey
Copy link
Contributor Author

I’d rather let the normal mechanics (and the error occur) but that can be changed during the beta if we feel it should be changed

@dmulcahey
Copy link
Contributor Author

I’d rather let the normal mechanics (and the error occur) but that can be changed during the beta if we feel it should be changed

I also think that if we hide the exception that the failure toast message in the UI won't happen?

Copy link
Member

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

LGTM

Successfully updated a Hue bulb and error handling also seems to work.

@dmulcahey dmulcahey force-pushed the dm/zha-better-firmware-updates branch from 3b39f4c to 2e9c48a Compare January 31, 2024 02:33
@dmulcahey
Copy link
Contributor Author

Huge thanks to @puddly and @TheJulianJES for helping with this!!!!

@dmulcahey dmulcahey changed the title Add update platform to ZHA Add update platform to ZHA (bumps Zigpy to 0.61.0) Jan 31, 2024
@dmulcahey dmulcahey changed the title Add update platform to ZHA (bumps Zigpy to 0.61.0) Add update platform to ZHA (bumps zigpy to 0.61.0) Jan 31, 2024
@dmulcahey
Copy link
Contributor Author

codecov is unrelated

@dmulcahey dmulcahey merged commit 3115af1 into home-assistant:dev Jan 31, 2024
51 of 53 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants