Using a sonoff wifi switch, in DIY mode (no flashing required), and octoprint to automatically turn on/off a 3d printer!
Basically just step 2 of this (all the rest can really be ignored): https://tasmota.github.io/docs/Sonoff-DIY/
- Follow instructions how to enter DIY mode from Sonoff. This is the excerpt from it:
- Long press the button for
510 seconds to enter pairing mode, then press another510 seconds to ender Compatible Pairing Mode (AP). The LED indicator should blink continuously.- From mobile phone or PC WiFi setting, an Access Point of the device named ITEAD-XXXXXXXX will be found, connect it with default password 12345678
- Open the browser and access http://10.10.7.1/
- Next, Fill in WiFi SSID and password. Once successfully connected, the device is in DIY mode.
That didn't work on my cellphone, but did work on my computer. Maybe I should have disabled cell data on my cellphone when trying it???
(Optional) shitty api documentation: https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/other/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v1.4.md
Use this octoprint plugin: https://github.com/kantlivelong/OctoPrint-PSUControl
With the system commands of (Replace your deviceId
and sonoff_ip
):
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "{deviceId}", "data": { "switch": "on" }}' http://{sonoff_ip}:8081/zeroconf/switch
and
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "{deviceId}", "data": { "switch": "off" }}' http://{sonoff_ip}:8081/zeroconf/switch
So I believe there is no security risk in sharing my example:
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "100108297b", "data": { "switch": "on" }}' http://192.168.0.189:8081/zeroconf/switch
and
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "100108297b", "data": { "switch": "off" }}' http://192.168.0.189:8081/zeroconf/switch
Figure out a command for sense. Needs to have exit code 0 == on
, 1 == off
(per https://github.com/kantlivelong/OctoPrint-PSUControl/wiki/Settings#sensing)