Can I run a python script before each print?

Hey guys,

Just installed the software and it runs great. Just have a possible QOL improvement.

I have my printer attached to a smart plug controlled through OpenHAB. It exposes a HTTP API for control. Is there a way to attach some sort of pre-print python script that runs every time I select a job so that I can automatically turn on/off the printer before printing? Ideally I'd also be able to connect/disconnect the printer via script as well instead of having to click the button manually.

Thanks!

You could technically do that with event subscriptions in config.yaml. Hook into the PrintStarted event with the command you want to run. But if it's a http api you might be able to use the OctoPrint-Webhooks plugin.