I’ve tried googling and searching around and I can’t find an answer to my query.
I’ve got a couple of rest commands setup (few webhooks, and WLED payload one following a tutorial).
I’ve stumbled on the fact that Octoprint has a API list and I’d love to update my existing automation to:
Turn on 3D printer plug
Instruct Octoprint to connect to said 3D printer.
Point 2 is not possible via the entities and Octoprint integration. Looking at the Ocotprint documentation there is a rest command to do point 2 and they provide an example which I list below. I know where I need to tailor to my setup (IP and API key).
The bit I’m struggling with is how do I rewite / structure the Octoprint example to go into the HA config.yml?
The Octoprint API example command is:
POST /api/connection HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef…
Status code 400. Payload: b’[{“command”: “connect”}]’
I can see entry in Octoprint matching error code 400. From what I can work out something is wrong around the payload set-up. Any suggestions?
I don’t know where this randon ‘b’ is coming in from as you can see its not in the rest command.
More investigation using hoppscotch I can get the api call working with the following curl (hashed IP and api key). How do I write this curl into a rest_command in yml?
Also, please use the “format text” button of the forum when you post any type of code.
Besides the fact that code is not aligned if you don’t (of extreme importance for YAML), you also get “typographical” double quotes rather than plain ASCII, which makes copy/paster a PITA.
Thanks for the help but even when using one line which I’ve used before it will would fail. It feels like its 99% there but I’m not experienced enough to work it out.
Rethinking what I wanted to do, I tried using a HA shell-command in yml and send a curl command over and that works.