Skip to content

Commit

Permalink
add @TASMOTAON and @TASMOTAOFF commands, #178
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Apr 21, 2022
1 parent 9f44218 commit 7ba092d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,34 @@ def processAtCommand(self, comm_instance, phase, command, parameters, tags=None,
if command == 'TASMOTAIDLEON':
self.powerOffWhenIdle = True
self._reset_idle_timer()
if command == 'TASMOTAIDLEOFF':
elif command == 'TASMOTAIDLEOFF':
self.powerOffWhenIdle = False
self._stop_idle_timer()
if self._abort_timer is not None:
self._abort_timer.cancel()
self._abort_timer = None
self._timeout_value = None
elif command == 'TASMOTAON':
plugip, plugidx = parameters.split(" ")
self._tasmota_logger.debug("Received TASMOTAON command, attempting power on of %s:%s." % (plugip, plugidx))
plug = self.plug_search(self._settings.get(["arrSmartplugs"]), "ip", plugip, "idx", plugidx)
self._tasmota_logger.debug(plug)
if plug and plug["gcodeEnabled"]:
t = threading.Timer(int(plug["gcodeOnDelay"]), self.gcode_on, [plug])
t.daemon = True
t.start()
return None
elif command == 'TASMOTAOFF':
plugip, plugidx = parameters.split(" ")
self._tasmota_logger.debug("Received TASMOTAOFF command, attempting power off of %s:%s." % (plugip, plugidx))
plug = self.plug_search(self._settings.get(["arrSmartplugs"]), "ip", plugip, "idx", plugidx)
self._tasmota_logger.debug(plug)
if plug and plug["gcodeEnabled"]:
t = threading.Timer(int(plug["gcodeOffDelay"]), self.gcode_off, [plug])
t.daemon = True
t.start()
return None

if command in ["TASMOTAIDLEON", "TASMOTAIDLEOFF"]:
self._plugin_manager.send_plugin_message(self._identifier,
dict(powerOffWhenIdle=self.powerOffWhenIdle, type="timeout",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Tasmota"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.1.2"
plugin_version = "1.1.3rc1"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 7ba092d

Please sign in to comment.