Skip to content

Plugin Configurations and Settings

Andre Lucca edited this page Mar 25, 2023 · 6 revisions

After Installing the Plugin

If the installation of the plugin goes correctly after the reboot of Octoprint you may see a new icon (bolt) on the top bar of Octoprint, this icon when clicked can force connect to the Tuya Device (if its Gray) and turn the Tuya Device On/Off. You can change this icon later but its color indicates the status of the Tuya device, where Gray means "not connected/not configured", Green means "connected and Device On" and Red means "connected and Device Off". You may go to the Octoprint configurations (wrench on the top bar) find the Plugins section and go to OctoTuya-SmartPlug.

OctoprintTopBar

PluginSettingMenu

Initial Settings Screen

In the main screen of the plugin configurations you may see a list of the configured Tuya devices (it will always have one) that you can click on the pencil to enter the specific configurations for that device, this configurations are explained below in this Wiki. Because its a list, you can add more than one Tuya device according to your needs.

Beyond the list of the devices you'll see two options Enable debug logging that when checked will enable the level Debug of the plugin log, this is very useful when troubleshooting connection issues or any other problems that may occur. The Enable polling of status when checked will open a field for typing the amount of minutes between connection checks, the default is 15. This option is very useful because it will make the plugin check its connections with the Tuya device every amount of minutes you've specified. In my tests with this enabled everything worked more reliable because it's constanly checking the device avoiding connection problems due to timeouts.

PluginInitialSettingScreen

Device Settings Screen

DeviceSettings

To enter the Device Settings Screen just click on the pencil on the left of the devices list. Here's how to use each of the options:

  • IP
    This is the IP Address of your Tuya Device, but be careful, this is not he IP that the Tuya/Smart Life app shows your device is connected at, the IP shown in the app is your Public IP, the IP your IOSP provides you, so don't use this one. The correct IP is the local IP your router has given to the device, usually looks like 198.162.X.X. To check this IP you must access your Router configurations to find a list of connected devices and the IP for each one. I highly recommend set the IP of the Tuya Device as a Reserved/Fixed one, because the Routers by default changes the IP of any device connected to it every period of time, if this happens to the device you are configuring here, the plugin simply won't be able to reach it anymore. To do it you must go to your Router configurations and look for some Reserved Address/Bind IP and MAC option that is usually under the DHCP configurations, of course this is very different for each of the Routers brands available.

  • Label
    This must be a unique name (if you use more than onde device with the plugin), cannot contain spaces, special character and must be all in capital letters. Its very important to follow this rules because this is the label that will be used with the GCODE comands to turn On/Off the device, and GCODE comands follow the exact same rules. If you use some character in the label that cannot be processed as GCODE the plugin will not find this device, therefore will take no action.

  • Device ID and Local Key
    This are the two infos you retrieved from Tuya Cloud Services in order to control your device. You should have this info at this point, if not go to this Wiki page

  • Smart Outlet Slot
    Some devices may have more than one Smart Outlet, so you must point witch oulet you want to control. The default will always be the number 1.

  • Octoprint top bar Icon
    This is the little icon that appears on the Octoprint top bar, this field only accept icons from FontAwesome so make sure to use one from their website.

  • Warning Prompt
    When checked, will always warn you if want to proceed or not when you click the plugin icon (bolt) on the Octoprint top bar. By clicking on the plugin icon it will immediately triggers the On/Off action. This option will not warn if the On/Off action were triggered by a GCODE command.

  • Warn While Printing
    When checked, will only warn you if want to proceed or not when you click the plugin icon (bolt) on the Octoprint bar if the Octoprint is on the Printing status. By clicking on the plugin icon it will immediately triggers the On/Off action. This option will not warn if the On/Off action were triggered by a GCODE command.

  • Use Protocol 3.3
    When checked uses the version 3.3 of the Tuya communication protocol. This is a recent version and seems to work way better with a various range of devices. I highly recommend to check this option.

  • Auto Connect to Printer
    When checked will force an Auto Connect from Octoprint to your Printer after the power On actions is taken. If checked will also show a numeric field, this is a delay in Seconds that will be introduced prior the Auto Connect action.

  • Auto Disconnect from Printer
    When checked will force an Auto Disconnect from Octoprint to your Printer before the power Off actions is taken. If checked will also show a numeric field, this is a delay in Seconds that will be introduced prior the Auto Disconnect action.

  • Use Device Countdown Timers
    When checked will use the built in timer feature of the Tuya Device(check image below), the same one you are able to use in the Tuya/Smart Life app. It has two fields On Timer that will set a timer to turn on the device after the specified period and Off Timer that will set a timer to turn off the device after the specified period. This values are in seconds, and are very useful if your Raspberry is connected in the printer PSU like mine, because if you turn the Tuya Device Off it will immediately cut the Pi power turning it off unsafely (wich is very risky in terms of currupting its SD Card), and if you send an OS command to the Octoprint shutdown safely it will not be able to control the Tuya Device anymore. So setting a timer that is built in the Tuya Device is perfect, because the control of the on/off action is no longer in Octoprint.

    AppTimer

  • GCODE Trigger
    When checked will allow the plugin to be triggered not only by the icon on Octoprint top bar but with GCODE commands. It has two extra fields GCODE On Delay that will add a delay before take the On action and the GCODE Off Delay that will add a delay before take the Off action.
    The default GCODE commands for this trigger:
    Turn On: M80 followed by the Label of your device, e.g. M80 ENDER3
    Turn Off: M81 followed by the Label of your device, e.g. M81 ENDER3
    This can be added on the start/end of your GCODE files and will be triggered as soon they enter the Octoprint Terminal, even if the terminal states "Command not found" or something similar.

    Alternative GCODE commands for this trigger:
    Some users with particular versions of Marlin may experience your print jobs being marked as failed after using the M81 command even if they are the offcial "Power Off" command of Marlin. To work around this I've tried dozens of different approaches, but the Octoprint module that make this plugin able to read terminal commands do not acknowlege other commands despite pure GCODE. So searching Marlin documentation I came across the G4 command, that pauses the queue of commands for a determined period of time. This will be harmless to print status or the printer itself if used with a very low period of time like 1ms and 2ms. So thats what I did:
    Turn On: G4 P1 followed by the Label of your device, e.g. G4 P1 ENDER3
    Turn Off: G4 P2 followed by the Label of your device, e.g. G4 P1 ENDER3

  • Run System Command After On
    When checked will run a OS command on Octoprint after take the On action. There are no limitations here and you can enter any OS command. It will also show a Delay field that like the other options will wait a period of time before executing the command, this field is in seconds.

  • Run System Command Before Off
    When checked will run a OS command on Octoprint before take the Off action. There are no limitations here and you can enter any OS command. It will also show a Delay field that like the other options will wait a period of time before executing the command, this field is in seconds.