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

PrusaLink config fails with message "Only PrusaLink API v2 is supported" #86230

Closed
aderusha opened this issue Jan 19, 2023 · 13 comments
Closed

Comments

@aderusha
Copy link

aderusha commented Jan 19, 2023

The problem

After I updated PrusaLink to the latest release 0.7.0rc2, the existing integration could no longer connect. I removed the integration and then re-started the setup process. Enter the hostname and API key and I'm met with the error "Only PrusaLink API v2 is supported". If I change the API key or hostname to an invalid combo, I get the message "failed to connect" as one would expect. This suggests the hostname and API key are correct, but something has changed in the PrusaLink project (maybe?).

PrusaSlicer is configured to access the same printer with the same API key and it works as expected.

What version of Home Assistant Core has the issue?

Home Assistant 2023.1.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

PrusaLink

Link to integration documentation on our website

https://www.home-assistant.io/integrations/prusalink/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No errors are logged in the core logfile while attempting to configure with the correct values. If I enter an incorrect hostname, I receive a message like this (this is an invalid hostname):

2023-01-19 08:30:56.254 ERROR (MainThread) [homeassistant.components.prusalink.config_flow] Could not connect to PrusaLink: Cannot connect to host prusalink02.derusha.net:80 ssl:default [Name does not resolve]

If I provide a bad API key, I get a message like this:

2023-01-19 08:39:59.378 ERROR (MainThread) [homeassistant.components.prusalink.config_flow] Could not connect to PrusaLink: 403, message='Forbidden', url=URL('http://prusalink01.derusha.net/api/version')

If I provide both correctly, I get the "Only PrusaLink API v2 is supported" message in the UI but no errors are logged. I cannot enable debug logging on the integration through the UI because it's not yet configured.

Additional information

No response

@home-assistant
Copy link

Hey there @balloob, mind taking a look at this issue 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 issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign prusalink Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


prusalink documentation
prusalink source
(message by IssueLinks)

@ProgrammedSoul
Copy link

ProgrammedSoul commented Jan 20, 2023

I have the same problem as I have to update PrusaLink recently, old version seem to have a bug now which will freeze a print.
According to this:
prusa3d/Prusa-Link-Web#222
"API type login in PrusaLink Web was temporary. In next release, only HTTP Digest will be allowed."
So it seems API Key authentication will no longer be a thing in the near future. Integration need to migrate to HTTP Digest authentication, which uses the same username and password you used to log into PrusaLink local.

@balloob
Copy link
Member

balloob commented Jan 20, 2023

@ProgrammedSoul you copied the wrong link and instead point at this issue.

@balloob
Copy link
Member

balloob commented Jan 20, 2023

There was an update for our Python package to support digest auth home-assistant-libs/pyprusalink#25. I closed it in the past as it required changing the guts and it seemed like API key support was fine.

@ProgrammedSoul
Copy link

@ProgrammedSoul you copied the wrong link and instead point at this issue.

Sorry, link is fixed.

@aderusha
Copy link
Author

aderusha commented Mar 9, 2023

Prusa-Link 0.7.0rc3 was released a few hours back. Loaded it up, pointed Home Assistant at it and same result: "Only PrusaLink API v2 is supported"

@mathieucarbou
Copy link

Same issue here :-( I initially thought it was my fault but discovered this issue after.

@mathieucarbou
Copy link

mathieucarbou commented Mar 20, 2023

The HA plugin is not working since PrusaLink 0.7.0rc2.

Readings:

from PrusaLink for MK3 0.7.0, API Key will be deprecated and not configured by default, but you can set it on Settings tab. New way to using PrusaLink API is HTTP Digest.

What I am unsure about is that a curl call works:

curl -H "X-Api-Key: xxxxxxxxxx" http://prusalink.local/api/v1/status

But the HA plugin is not able to communicate through API.

Error in HA:
image

It might be is because of this check: https://github.com/home-assistant/core/blob/dev/homeassistant/components/prusalink/config_flow.py#L49

For the latest RC version, Prusalink returns:

{
  "api": "0.9.0-legacy",
  "server": "0.7.0rc3",
  "original": "PrusaLink I3MK3S",
  "text": "PrusaLink 0.7.0rc3",
  "firmware": "3.11.0-4955",
  "sdk": "0.7.0rc3",
  "capabilities": {
    "upload-by-put": true
  },
  "hostname": "PrusaLink"
}

I don't know where that check comes from because from what I see in Prusalink, there is no v2 api...

@john-rodewald
Copy link

john-rodewald commented Mar 20, 2023

I encountered a similar problem on the SL1S: prusa3d/Prusa-Firmware-SL1#78


Since Prusa recommends Digest over API keys (and indeed plans to deprecate API keys), I've extended pyprusalink (the home-assistant lib that talks to PrusaLink) to support Digest auth: home-assistant-libs/pyprusalink#25

The PR was rejected, but I run it locally nonetheless, with an updated integration of pyprusalink on home-assistant/core. In this fork, I work around the problem by not checking for the API version. Some of the metrics work fine, others do not. Obviously that's not a proper solution. https://github.com/john-rodewald/core/tree/feat/prusalink-update

@mathieucarbou
Copy link

I encountered a similar problem on the SL1S: prusa3d/Prusa-Firmware-SL1#78

Since Prusa recommends Digest over API keys (and indeed plans to deprecate API keys), I've extended pyprusalink (the home-assistant lib that talks to PrusaLink) to support Digest auth: home-assistant-libs/pyprusalink#25

The PR was rejected, but I run it locally nonetheless, with an updated integration of pyprusalink on home-assistant/core. In this fork, I work around the problem by not checking for the API version. Some of the metrics work fine, others do not. Obviously that's not a proper solution. https://github.com/john-rodewald/core/tree/feat/prusalink-update

I got the idea to patch it locally too but these files are not accessible when running HA OS I think...

@balloob
Copy link
Member

balloob commented Mar 20, 2023

Curl working means the API works just fine, which sounds like you're chasing the wrong source of your problem. The API key is not the problem but it's PrusaLink versioning. That check actually works correctly in Home Assistant because as John wrote, not everything works when you remove that check.

I am going to close this issue because it's a feature request to add support for more printers, and we track feature requests on the forums.

@balloob balloob closed this as completed Mar 20, 2023
@mathieucarbou
Copy link

Makes sense.
Thanks!

So the integration is only working atm with the mini...

@mathieucarbou
Copy link

@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants