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

Upgrade Prusa Link to new Digest Authentication and /v1/ API #103396

Merged
merged 44 commits into from Dec 19, 2023

Conversation

Skaronator
Copy link
Contributor

@Skaronator Skaronator commented Nov 4, 2023

Breaking change

  • printer.state now contains several new statuses, most importantly "attention" which always needs user invention
  • Firmware 4.7.0 is now the minimum version for Prusa XL and MK4
  • Firmware 5.1.0 is now the minimum version for Prusa Mini since 4.7.x and 5.0.x aren't available for the Mini

Proposed change

This PR updates pyprusalink library.

Tested with my XL on 5.1 firmware

image

New Attention Status:
image

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 Black (black --fast 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 Nov 4, 2023

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

Code owner commands

Code owners of prusalink 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 prusalink Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@Skaronator Skaronator marked this pull request as ready for review November 5, 2023 11:13
@rforro
Copy link
Contributor

rforro commented Nov 7, 2023

From config_flow.py following code needs to be removed or modified, because PrusaLink for RaspberryPi uses V1 as well, but advertise api version as 0.9.0-legacy.

try:
        if AwesomeVersion(version["api"]) < AwesomeVersion("2.0.0"):
            raise NotSupported

The Prusa api versioning is a bit mess they advertise different numbers on MINI/MK4/XL/PrusaLink(RaspberryPi), thats why checking api value is bad.

EDIT: After some digging I think, that buddy FW MINI/MK3.5/MK4 will report 2.0.0 everytime. It doesn't matter if they support V1 or not. So the version problem is only PrusaLink for RaspberryPi. Maybe they just forget to set it to 2.0.0. I will clarify this.

Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Please make sure CI is passing

@home-assistant
Copy link

home-assistant bot commented Nov 7, 2023

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft November 7, 2023 09:22
@edenhaus
Copy link
Contributor

edenhaus commented Nov 7, 2023

  • printer.telemetry.material is no longer available. The new API doesn't is currently far too slow to fetch this information. Additionally, the current implementation is broken for multi material prints.

Would it be possible to use the old API for this endpoint? So we can avoid the breaking change?

@Skaronator
Copy link
Contributor Author

@rforro I would leave that version condition as it is unless anyone who owns an MK3x with a Raspberry Pi running Prusa Link wants to contribute. But that change can happen in a future PR.

@edenhaus I'll look into it.

@Skaronator
Copy link
Contributor Author

I've re-added the Material sensor using the old API. So the only breaking change is now the Enum in the printer.state sensor.

@Skaronator
Copy link
Contributor Author

Implemented all review suggestions. Thanks @edenhaus!

@Skaronator Skaronator marked this pull request as ready for review December 19, 2023 14:29
@home-assistant home-assistant bot marked this pull request as draft December 19, 2023 15:13
@Skaronator Skaronator marked this pull request as ready for review December 19, 2023 16:16
@Skaronator Skaronator marked this pull request as draft December 19, 2023 16:17
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @Skaronator 👍

@edenhaus
Copy link
Contributor

Test failure unrelated:
FAILED tests/helpers/test_script.py::test_wait_template_with_utcnow - Failed: Timeout >9.0s

@edenhaus edenhaus marked this pull request as ready for review December 19, 2023 17:07
@edenhaus edenhaus merged commit 91f8d3f into home-assistant:dev Dec 19, 2023
48 of 49 checks passed
@Skaronator Skaronator deleted the prusalink-v2 branch December 19, 2023 18:24
@Skaronator
Copy link
Contributor Author

Awesome thanks for the review!

@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
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.

None yet

4 participants