jneilliii / OctoPrint-PrintScheduler

MIT License
10 stars 2 forks source link

Question: How do I integrate this with your tasmota plugin? #6

Closed JoeThompsonGitHub closed 3 years ago

JoeThompsonGitHub commented 3 years ago

Hi, thanks for making this plugin. I've been long awaiting something like this. How would I integrate this with your tasmota plugin? In the scheduling settings there needs to be a way of turning the printer on with a command similar to M80 x.x.x.x 1 before a print runs. How would you suggest I do this?

jneilliii commented 3 years ago

In its current state it would require to use a system command before print starts (plugin settings) to send an api request to the tasmota plugin since you can't send gcode with the printer disconnected.

JoeThompsonGitHub commented 3 years ago

Thanks for confirming. Do you have an example of this command please as a workaround?

jneilliii commented 3 years ago

I sure do...these curl commands should in theory work...

https://github.com/jneilliii/OctoPrint-Tasmota/wiki/API

JoeThompsonGitHub commented 3 years ago

Still not getting this to work. I tried this command in putty running as sudo:

curl -s -H "Content-Type: application/json" -H "XXXXXXXXXXXXXXXXXXXXXXXXX" -X POST -d '{ "command":"turnOn", "ip":"10.0.x.x", "idx":"1" }' http://10.0.x.x/api/plugin/tasmota

And I am getting it return Insufficient rights

I even tried using the global API key to see if it was a octoprint access issue. Any ideas?

jneilliii commented 3 years ago

I'll have to test. There should be no reason that doesn't work unless your user account doesn't have permissions. You created an application key for your user account and tried that first?

JoeThompsonGitHub commented 3 years ago

Yes - initially I tried the global key and it didn't work, remembering that was a bit silly. So I created a tasmota user with operator permissions and added tasmota device special permissions ontop, generated a key and that is the one I'm using in my curl command. Surely by testing with the global key it should negate any octoprint access issues and points the issue to the plugin?

jneilliii commented 3 years ago

Did you validate that the command works via SSH by chance? Also, your command might benefit from using http://localhost/api/plugin/tasmota since it's running on the same box.

Insufficient rights could potentially indicate an issue on the Tasmota plugin side, but what you did with application keys should work.

JoeThompsonGitHub commented 3 years ago

Yes, all verified by SSH and thats where I had it return Insufficient rights.

See if you can replicate it your end.

jneilliii commented 3 years ago

I am able to replicate your exact issue, so probably a bug on the Tasmota side. I'll investigate further and handle that in the above issue.

JoeThompsonGitHub commented 3 years ago

Thank you jneilliii

jneilliii commented 3 years ago

Actually your command was wrong, which is why it was happening...here is the correct working command for you. Looks like you inadvertently removed part of the header and replaced the whole section with your API key.

curl -s -H "Content-Type: application/json" -H "X-Api-Key: XXXXXXXXXXXXXXXXXXXXXXXXX" -X POST -d '{ "command":"turnOn", "ip":"10.0.x.x", "idx":"1" }' http://localhost/api/plugin/tasmota
JoeThompsonGitHub commented 3 years ago

You are correct, operator error on my part. I tested this on another relay I have and its worked. I look forward to test this print scheduler now.