How to send commands/control printer through personal web page

What is the problem?

I am currently setting up a home automation control hub webpage. I would like it to have the ability to control my Ender 3 as well. Some controls I would like to have are starting/stopping prints, moving the extruders position, and control a light connected to a gpio pin. I have custom control buttons and gcode for this, OCTO0 and OCTO1, off and on respectively.

I am also using a raspi zero for the web server if that helps. The web page will only be able to be accessed on my LAN, not remotely. The web page uses HTML5

What did you already try to solve it?

  • Searched for a plugin that would create an embed so I can add it to webpage
  • Add iframe to web page pointing to "http://octopi.local/#control"
  • Tried to figure out if I can control with javascript and an api remotely... here
    It seemed like the javascript could only work locally on the Octopi.

System Info

browser.user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 OPR/77.0.4054.254
connectivity.connection_check: 1.1.1.1:53
connectivity.connection_ok: true
connectivity.enabled: true
connectivity.online: true
connectivity.resolution_check: octoprint.org
connectivity.resolution_ok: true
env.hardware.cores: 4
env.hardware.freq: 1200
env.hardware.ram: 915058688
env.os.bits: 32
env.os.id: linux
env.os.platform: linux2
env.plugins.pi_support.model: Raspberry Pi 3 Model B Rev 1.2
env.plugins.pi_support.octopi_version: 0.17.0
env.plugins.pi_support.throttle_state: 0x0
env.python.pip: 19.3.1
env.python.version: 2.7.16
env.python.virtualenv: true
octoprint.safe_mode: false
octoprint.version: 1.6.1
systeminfo.generator: systemapi

Additional information about your setup

  • OctoPrint 1.6.1
  • Python 2.7.16
  • OctoPi 0.17.0

Did you see the API docu?
And you mention home automation. If you by chance use mqtt in that context you may find some inspiration starting here.

Why does this solution not work?

The link you found for the API is using it from the OctoPrint UI, but you can call the API from anywhere else, just following the API docs.

I did not see the API Docs, thank you! I think they have everything I am going to need! I do not use mqtt, but I will have to look into it.

The iframe would not display anything. Thank you, it looks as if I will have to look further into my solutions...

You probably need to enable the option to allow framing in the settings to use and iframe.