Octoprint Safe Shutdown

Hi all,

I am trying to create a safe shutdown sequence for my Octoprint running on a seperate Pi3b.

I am using Node-Red inside home assistant and I have an entity called "button.octoprint_shutdown_system" with a resting status of unknown.

What I would like to happen is on a button press to shutdown Octoprint wait one minute and then turn off the smart switch.

I just cant figureout the first part so any help would be appreciated.

Thanks!

EDIT: flow below:

[{"id":"7375360fe34b709d","type":"stoptimer","z":"ee46ed1da81de40d","duration":"30","units":"Second","payloadtype":"num","payloadval":"0","name":"shut down delay timer","x":600,"y":220,"wires":[["8af7efb5cf340ff9"],[]]},{"id":"8af7efb5cf340ff9","type":"api-call-service","z":"ee46ed1da81de40d","name":"Printer Power Off","server":"ad021f45.a359d","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.tuya_emswitch_1_shark_3dp_unassigned"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":870,"y":200,"wires":[[]]},{"id":"943def59d1f310a1","type":"server-state-changed","z":"ee46ed1da81de40d","name":"Printer Power","server":"ad021f45.a359d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.3d_printer","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":220,"wires":[[],["bb8be3b366bd40dd"]]},{"id":"bb8be3b366bd40dd","type":"api-call-service","z":"ee46ed1da81de40d","name":"Printer Power Off","server":"ad021f45.a359d","version":5,"debugenabled":false,"domain":"script","service":"toggle","areaId":[],"deviceId":[],"entityId":["button.octoprint_shutdown_system"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":350,"y":220,"wires":[["7375360fe34b709d"]]},{"id":"ad021f45.a359d","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

You might get more responses if you posted your question on the HA forum (as very few people use HA on this forum).

If you can share your Node-RED flow I'm sure people (including myself) will take a look at it and see if we can help.

Thanks for replying Dave,

I didnt have much of a flow, as I can't get this node working. I have edited the initial post with the flow. :slight_smile:

I will try the HA forums too, but as I am using Node-Red and not YAML I assumed this would be the best place.

If what you want to do is to send a message to shutdown Octoprint then wait one minute and send another message to turn off the switch then you can do that with the Trigger node.

If you add the octoprint mqtt plugin you can communicate between NR and octoprint. You could wait for the print to finish and have Octoprint publish an mqtt msg. When NR receives it, wait another 10 minutes (in case you are setting up for another print) then send a shutoff command to the smart plug the printer is connected to. Then wait a bit longer and have NR (using an exec node) send a shutdown command to the Pi.

I did try the MQTT plugin and had some problems with it, I forget exactly what. I ended up using the http interface directly, which is not difficult.

Thanks for the reply, are you talking the MQTT plug in Home Assistant? That is how my Octoprint is currently connected. If not I will take a look in NR.

Thanks for the tip. I will take a look!

I mean the OctoPrint MQTT plugin

No, the mqtt plugin for Octoprint itself. That allows it to be controlled via mqtt. I don't use HA.