Node-red control UI

Blockquote
create a file "apikey" under /home/pi/ with the config as json:

I take it this is on the PI that Octoprint is running on and I can call it "apikey" ?
any file permissions I need to worry about?

I run Node-red on my Synology NAS box in a docker container just in case that makes any difference
Thanks for the more detail :slight_smile:

Hello.

I take it this is on the PI that Octoprint is running on and I can call it "apikey" ?

This files is required on the system that execudes node-red.

Easy way:
Import this nodes:
image

[{"id":"42743e77.9ce29","type":"template","z":"16446ae6.4f4515","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n  \"apikey\": \"Octoprint-API Key\",\n  \"ip\": \"192.168.1.210\",\n  \"port\": \"5000\",\n  \"webcam\": \"http://fullurltowebcam\"\n}","output":"str","x":300,"y":740,"wires":[["4584efe6.699b6"]]},{"id":"cb9852f0.48032","type":"inject","z":"16446ae6.4f4515","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":740,"wires":[["42743e77.9ce29"]]},{"id":"4584efe6.699b6","type":"file","z":"16446ae6.4f4515","name":"","filename":"apikey","appendNewline":true,"createDir":false,"overwriteFile":"true","x":470,"y":740,"wires":[[]]}]

Edit the template to your values.
image

Initiate the inject and change the filepath in the main flow to an relative path.
image

image

Greetings,
Christian

@Drak41

Did the flow solve your problem?

Thanks @Schnello that's what I needed :slight_smile:

Hi Schnello
Kann ich dich Irgendwo kontaktieren? Hab da ein paar fragen

Lg

Just a quick question about this, are you 'polling' the Octoprint API every X seconds, or are you using the MQTT plugin to get info from Octoprint to NodeRED?

Hi.

Its only a http request.

Hi

This was a really good flow. Thanks for that! :smiley:

Do you have any good commands for canceling the print. Ive tried to add a bunch of gcodes to a command button.
And the printer responds, but continiues after it have "cancelled" it.

The commands is:
{"commands":["G91","G1 E-2 F2700","G1 E-2 Z0.2 F2400","G1 X5 Y5 F3000","G1 Z10","G90","G1 X0 Y{machine_depth}","M106 S0","M104 S0","M140 S0"]}

I have put it at the same place as filament change, as i just want tp cancel if something is printing...

Hey. I guess the best way is:
http://docs.octoprint.org/en/master/features/action_commands.html

Yes! Thank you!

I've got it to work with the command " { "command": "M118//action:cancel" } " from node-red

:smiley:

Hello!
I have a question about your flow, which http request are you using?
When I import the your flow the field of the http request is blank and I don't know what to do...

Sorry for the late response:

I have a question about your flow, which http request are you using?
When I import the your flow the field of the http request is blank and I don't know what to do...

The config ist loaded from the file "apikey":
image

File Content:
{
"apikey": "Octoprint-API Key",
"ip": "192.168.1.210",
"port": "5000",
"webcam": "http://fullurltowebcam"
}

and is used in this function:

image

Greetings

Hello! New to Red Node and Octoprint and I would like to get this running on my mac vs pi. I've followed the discussion but get Unexpected token < in JSON at position 0 for the json nodes after the switch. I also tried http://localhost:5000/#term for the http request URL but get some warning messages. Any suggestions on the api / http settings for working off a mac? Thanks in advance!

Make sure you're requesting the API routes (that do return JSON) - anything under /api/. Requesting the root page will get you the HTML used to render it... And that's not going to work here.

Hi. I did not fully unterstand what you are doing.

First the flow reads the config from the apikey file:
image

This config file has the following structure:
{"apikey":"83cbe565fc333333333333331eab2","ip":"192.168.1.30","port":"5000","webcam":"http://uplink.XXXX.eu:8080/video"}

I'm trying to work locally on the same laptop as the octoprint server (no pi) for development. The octoprint server is connected and running. Not sure what to put in for IP address. I also do not have a webcam so I'm not worried about that right now.

{
"apikey": "FACD0D3EC0784E969152C36397FD2917",
"ip": "127.0.0.1",
"port": "5000",
"webcam": "http://127.0.0.1/video"
}

Hi.

In this case this should work:
{
"apikey": "FACD0D3EC0784E969152C36397FD2917",
"ip": "127.0.0.1",
"port": "5000"
}

Thanks Shnello! That worked.

1 Like

Hey guys,

I just want to add a pause/resume to my prints thought Node Red

I have shutdown ok, but I don't know how to add something more complicated?

image

Thanks :slight_smile:

Hi @Schnello ,

thanks for sharing the flow. I am a Node Red beginner and still trying to understand your flow. I have two questions about it:

Webcam:
I can't get the webcam to work in the node red dashboard. I have included the webcam as stated in the octoprint installation guide. The stream can be found at http://192.168.178.157:8080/?action=stream. The config file looks like this:
{
"apikey": "KEYXXXXXX",
"ip": "192.168.178.157",
"port": "5000",
"webcam": "http://192.168.178.157:8080"
}
Unfortunately, it does not works this way. Even with the URL parameters, no stream appears in the dashboard. What am I doing wrong?

node red:
I am still a node red beginner and this is the first time I have seen the use of "link in" and "link out". Therefore I would like to ask a question:
Does this only work within a flow or also across flows?
This is actually something like a function/procedure call in node red (without returning the result), right?.

Many thanks and greetings
Sepp