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 prusalink legacy api support (MK3s+) #102014

Closed
wants to merge 2 commits into from

Conversation

rastislavpapp
Copy link

@rastislavpapp rastislavpapp commented Oct 14, 2023

Proposed change

I've tried setting up Prusalink integration with the most popular MK3S+ printer, and was suprised it only works with Prusa Mini or MK4. I have no knowledge of python, but I've tried to fix this anyway, as it was bothering me.
I've looked at the API calls which the integration makes, and tried the same calls against my 0.7.0 prusalink, and everything except thumbnails (which I've fixed) seemed to work as-is. So I basically just deleted the condition that your prusalink should be of version 2.0.0+.
I've tried to run the tests, but I was not able to get some of them to work (even without my changes), neither on Windows, nor WSL2 (Ubuntu). The ones that worked before my changes still work after them :-)

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:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @rastislavpapp

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

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
Copy link

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.

@juliekoubova
Copy link

@rastislavpapp the PR is still marked as draft, is there any work remaining? can I help somehow?

@rastislavpapp rastislavpapp marked this pull request as ready for review October 20, 2023 14:20
@rastislavpapp
Copy link
Author

sorry, I did not realize it was in draft state :-)

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

I think the big problem in this PR should be solved in the library itself. We usually only do wrappers when its a library we have a hard time updating or that needs just a bit extra. In this case, the pyprusalink lib is located in a organisation which holds some libraries used by HA and there seem to be some open PRs that look like they are adding v1 support. (https://github.com/home-assistant-libs/pyprusalink/pulls).

I would prefer that we keep the device specific connections in the library and then if there are any API changes, update the lib and changes in HA.

@home-assistant home-assistant bot marked this pull request as draft October 20, 2023 14:39
@MartinHjelmare MartinHjelmare changed the title prusalink - support for legacy api (MK3s+) Add prusalink legacy api support (MK3s+) Oct 20, 2023
async def get_large_thumbnail(self, path: str) -> bytes:
if self.is_legacy:
"""Get a large thumbnail."""
async with self.api.request("GET", f"api/thumbnails{path}.orig.png") as response:
Copy link
Member

Choose a reason for hiding this comment

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

This belongs in the 3rd party library.

@MartinHjelmare
Copy link
Member

Closing this PR since it's not the correct approach per above comments.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 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.

PrusaLink integration does not work with the current version PrusaLink 0.7.0
5 participants