Octoprint RestFull switch

Hey guys,

So ive moved most of my stuff over to Node Red. Worked out how to send the shutdown but need to insert the JSON for the pause/resume and home

Anyone done that?

shell_command:
  octoprint_pause_resume: "curl -s http://192.168.1.47/api/job -d '{\"command\":\"pause\",\"action\":{\"toggle\"}}' -H 'Content-Type: application/json' -H 'X-Api-Key: FE8Dxxxxx4DC9A8712773AC817A5D'"
  octoprint_autohome: "curl -s http://x.x.x.x/api/printer/command -d '{\"command\":\"G28 W\"}' -H 'Content-Type: application/json' -H 'X-Api-Key: XXX'"
1 Like

I know this is an old comment, but is the gcode viewer still working for you? If so, could you post your yaml/setup for it?

I have the Pretty GCode plugin installed on Octoprint and it shows correctly there. Full screen URL does too, but when I visit from incognito it brings up the sign-in page. I’m using MQTT Octoprint - I’ve been able to pull in everything else (axis controls, power controls, stl viewer, etc) into HA, so this is the last thing I’m trying to get working.

I’ve added the IP to a webpage card but it shows up blank.

type: iframe
url: http://192.168.68.145/?fullscreen=1#tab_plugin_prettygcode
aspect_ratio: 100%

Have you enabled this switch in the settings:

EDIT: I’ve tried this and get the log in page but does not log in

I did try that, I haven’t rebooted Octoprint since I’m in the middle of a print, so I’m guessing that’s why I can’t see the sign-in page. I’m also going to try installing this to see if it auto logs me in once I can see it in HA: OctoPrint-AutoLoginConfig

1 Like

No that doesn’t work either. I did a search and its a known issue, something to do with samesite or reverse proxy.

While this is an old thread, having taken a lot of help from this thread (thanks all), I wanted to share my variation of configuration.yml setup in case its of help as I’ve found using the restful integration to be a cleaner experience than curl via shell_command, allowing for easy passing of the api key via secrets and having all my logic in one place.

rest_command:
  octopi_disconnect:
    url: "http://octopi.local/api/connection"
    method: post
    headers: 
        X-Api-Key: !secret octopi_key
    content_type: "application/json"
    payload: "{ \"command\": \"disconnect\" }"
    
  octopi_connect:
    url: "http://octopi.local/api/connection"
    method: post
    headers: 
        X-Api-Key: !secret octopi_key
    content_type: "application/json"
    payload: "{ \"command\": \"connect\" }"  
    
  octopi_restart_klipper:
    url: "http://octopi.local/api/system/commands/custom/octoklipper_restart"
    method: post
    headers: 
        X-Api-Key: !secret octopi_key
    content_type: "application/json"
    

secrets.yaml

octopi_key: "secret api key"

I’ve been able to use above to automate the restarting of klipper after a printer start