Notifications
Clear all

REST command to set tool0 temperature?  

  RSS
luma
 luma
(@luma)
Member
REST command to set tool0 temperature?

I'm working through an attempt to interact with Prusa Link from Home Assistant as the official integration is completely broken.  I ran across this spec which helped me pull the info I need about current status, telemetry, etc.

The API has a legacy mode where it behaves like OctoPrint which is nice as there are a lot of examples etc for that.  I'm using curl here to interact with the Prusa Link API.  My goal is to be able to set the hotend "tool0" target temperature.  The following command works to set the print bed target temp to 75°:


PRUSALINK_HOST=prusalink01.example.com
PRUSALINK_USER=administrator
PRUSALINK_PASS=password

curl -X POST  http://$PRUSALINK_HOST/api/printer/bed  -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d '{"command":"target","target":75}' --digest -u $PRUSALINK_USER:$PRUSALINK_PASS

From my read of the docs (and referencing OctoPrint which the API is based on), I think I should be able to set the tool0 temp like this:


curl -X POST  http://$PRUSALINK_HOST/api/printer/tool  -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d '{"target":{"command":"target","targets":{"tool0":160}}}' --digest -u $PRUSALINK_USER:$PRUSALINK_PASS

Here's how that JSON breaks down:

{
  "target": {
    "command": "target",
    "targets": {
      "tool0": 160
    }
  }
}

I get a 204 return code when sending both commands, but the tool0 target doesn't seem to change.  Bed target works as expected.

Anyone have any ideas how one can set the tool0 temp via curl?

Best Answer by Tojik:

Hi, you seem to have misread the docs. I checked the code and it looks like it should work when you provide the json as described below in the screenshot. Let me know if that ends up not being the case. 🙂

Posted : 24/07/2023 12:37 pm
Tojik
(@tojik)
Member Moderator
RE: REST command to set tool0 temperature?

Hi, you seem to have misread the docs. I checked the code and it looks like it should work when you provide the json as described below in the screenshot. Let me know if that ends up not being the case. 🙂

Posted : 31/07/2023 2:59 pm
luma liked
luma
 luma
(@luma)
Member
Topic starter answered:
RE: REST command to set tool0 temperature?

 

Posted by: @tojik

Hi, you seem to have misread the docs

Yeah I have a habit of that, and let's also mix in some "completely misunderstood the docs" while we're at it 😀  Your JSON above gave me the detail I was missing!

Here's a working script to set the tool temp with some nice help from my new friend @Tojik

PRUSALINK_HOST=prusalink.example.com
PRUSALINK_USER=administrator
PRUSALINK_PASS=password
BED_TARGET=60
TOOL0_TARGET=160

curl -X POST   http://$PRUSALINK_HOST/api/printer/bed   -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d "{\"command\":\"target\",\"target\":$BED_TARGET}" --digest -u $PRUSALINK_USER:$PRUSALINK_PASS
curl -X POST   http://$PRUSALINK_HOST/api/printer/tool   -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d "{\"command\":\"target\",\"targets\":{\"tool0\":$TOOL0_TARGET}}" --digest -u $PRUSALINK_USER:$PRUSALINK_PASS

Posted : 31/07/2023 4:00 pm
Tojik liked
Share: