OctoPod feature request: custom command strings

Maybe there's a way to do this elsewhere, in OctoPrint's UI, possibly... but I think OctoPod would be the best place for this, for me:

I'd like a programmable button that will execute a custom command or set of commands. The instance that comes to mind is for changing filament. I'd like to heat up the hotend, wait for it to get to temperature, speedily retract 450mm of filament (give or take), and then shut down the hotend. That way I can just head over to the printer and change the spool at my leisure.

I'm not familiar with OctoPod, but I think I remember seeing that it supports custom controls that are configured in OctoPrint's config.yaml, but I might be wrong.

1 Like

I don't think you are:

OctoPrint allows you to add custom controls to the โ€œControlโ€ tab of its interface. Control types reach from simple buttons which trigger sending of one or more lines of GCODE to the printer

That's exactly what I'm looking for... although having that same capability in OctoPod would suit me better.

That's what I mean. I think once you've added them in OctoPrint, I think OctoPod will then show those buttons in its interface, but I'm not sure.

1 Like

Whhhhhaaaaaaaaaaaat....? I guess I didn't think that's how OctoPod got its UI, but I suppose that could be! I'll give it a try and report back.

Yeah, based on this post, it was added to support this.

Here's what I have added to the end of config.yaml:

controls:
  - name: Filament
    layout: horizontal
    children:
    - name: Unload
      commands:
	  - M302 S0 P1 #disable cold extrusion checking
	  - G0 E450 F500 #retract filament 450mm
      - M302 S170 P0 #enable cold extrusion checking
    - name: Load
      commands:
	  - M104 S200 #set nozzle temp to 200
	  - M109 S200 #wait for nozzle temp to reach 200
	  - G0 E440 F300 #insert filament 440mm
	  - M400 #wait
	  - M104 S0 #set nozzle temp to 0

Should that work? I'm mid-print and will reboot OctoPrint afterwards...

Looks good, just make sure that the indentation is done with all spaces. When I copied it over it looked like there were a couple of tabs in there, but that could have been because of grabbing it from email. Also, make sure to match the number of spaces currently in your config.yaml. For example, my config.yaml on my development machine is 4 spaces per indentation instead of 2.

controls:
-   children:
    -   commands:
        - M302 S0 P1
        - G0 E450 F500
        - M302 S170 P0
        name: Unload
    -   commands:
        - M104 S200
        - M109 S200
        - G0 E440 F300
        - M400
        - M104 S0
        name: Load
    layout: horizontal
    name: Filament

Once you've added it to config.yaml, restart octoprint and the parts you added should get moved into the alphabetical location (after appearance).

image

image

1 Like

Good catch on both counts... yes, there were some tabs present despite the fact that I read "no tabs." And the spacing in my added code was short. Thanks!

Modification failed, in that I could no longer connect to the printer via the browser. The browser UI would come up, and the contents of the "Controls" tab was no different from default. I could SSH in and see that the code was inserted in config.yaml between appearance: and feature: despite the fact that I added it to the end of the file. I could not connect to the folders on Pi from Windows at all.

I deleted that section in the script editor, saved, and rebooted. Only then could I connect to the printer through the browser UI.

The only thing I can think of is that something's wonky with my syntax.

EDIT: I tried again with some edited spacing. Here's my config.yaml file in its entirety:

accessControl:
    salt: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
api:
    key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
appearance:
    color: blue
    name: OctoPi - Ender 3 Pro
    showFahrenheitAlso: true
feature:
    modelSizeDetection: false
plugins:
    announcements:
        _config_version: 1
        channels:
            _blog:
                read_until: 1585659600
            _important:
                read_until: 1521111600
            _octopi:
                read_until: 1573722900
            _plugins:
                read_until: 1587859200
            _releases:
                read_until: 1583322300
    cura:
        cura_engine: /usr/local/bin/cura_engine
    discovery:
        publicPort: 80
        upnpUuid: 33735e72-aed3-4645-84db-00f162c8b31f
    errortracking:
        unique_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    growl: null
    octopod:
        _config_version: 8
        tokens:
        -   apnsToken: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            date: 2020-04-17 09:08:01.786028
            deviceName: xxxxxxxxxxxxxxxxx
            languageCode: en
            printerID: x-coredata://xxxxxxxxxxxxxxxxxxxx/Printer/p1
            printerName: OctoPi - Ender 3 Pro
    psucontrol:
        _config_version: 3
    softwareupdate:
        _config_version: 7
    tracking:
        enabled: false
        unique_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
printerProfiles:
    default: _default
serial:
    autoconnect: true
    baudrate: 0
    port: AUTO
server:
    commands:
        serverRestartCommand: sudo service octoprint restart
        systemRestartCommand: sudo shutdown -r now
        systemShutdownCommand: sudo shutdown -h now
    firstRun: false
    onlineCheck:
        enabled: true
    pluginBlacklist:
        enabled: true
    secretKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    seenWizards:
        corewizard: 3
        tracking: null
temperature:
    profiles:
    -   bed: 100
        chamber: null
        extruder: 210
        name: ABS
    -   bed: 60
        chamber: null
        extruder: 180
        name: PLA
webcam:
    ffmpeg: /usr/bin/ffmpeg
    snapshot: http://127.0.0.1:8080/?action=snapshot
    stream: /webcam/?action=stream
    timelapseEnabled: false
    watermark: false
controls:
    -   children:
        -   commands:
            -   M104 S200 #set nozzle temp to 200
            -   M109 S200 #wait for nozzle temp to reach 200
            -   G0 E440 F300 #insert filament 440mm
            -   M400 #wait
            -   M104 S0 #set nozzle temp to 0
            name: Load
        -   commands:
            -   M302 S0 P1 #disable cold extrusion checking
            -   G0 E450 F500 #retract filament 450mm
            -   M302 S170 P0 #enable cold extrusion checking
            name: Unload
    layout: horizontal
    name: Filament

Still doesn't work. Worse, in fact, the UI doesn't even load with this file. I deleted the additions and OctoPrint loads fine. I'm so glad I put my power supply on a remote over the weekend...

Editing the config.yaml manually can be cumbersome and is error prone. You might want to try with the Custom Control Editor plugin.

I think you just need to take this part out...

Actually, you need to take out all those "#...." parts, pure gcode only. If you're trying to have comments you should be using a ; instead of #.

I can see how that would be the case... plugin, you say? I didn't know there was such a thing. Downloading now.

You haven't steered me wrong yet, but I don't know why a comment would be causing issues. I'll play with the Custom Control Editor and see how badly I can mess things up...

Ah, gotcha. Well, in any case, using the plugin worked great:

...and those controls even appear in OctoPod. VERY nice! Now I just need to test them out.
Thanks!

EDIT: here's what the added snippet looks like in config.yaml:

controls:
-   children:
    -   name: Load
        script: M104 S200 M109 S200 G0 E440 F300 M400 M104 S0
    -   name: Unload
        script: M302 S0 P1 G0 E-450 F500 M302 S170 P0
    layout: horizontal
    name: Filament

Don'f forget to mark the solution...

Oh, I actually already had above... but unfortunately the buttons don't work in either the browser UI or in OctoPod yet. The buttons click in the browser UI but don't actually do anything. In OctoPod, I get a "script not found" error. Odd.

This is getting me close, though. I'll continue to work on it.

EDIT: I'll bet instead of Script, I need to use Command. I thought "Command" meant a single command, but upon selecting it, the input field is labeled "Commands" (plural). I'm in the middle of another print or else I'd test it. Making some facemask holders for the folks at the local grocery...

Yep, command is probably the correct option.