Skip to content

Commit

Permalink
add websocket messages back in, #109
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Dec 9, 2020
1 parent 016c5d6 commit 95648d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def turn_on(self, plugip, plugidx):
"Resetting idle timer since plug %s:%s was just turned on." % (plugip, plugidx))
self._waitForHeaters = False
self._reset_idle_timer()
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="on",ip=plugip,idx=plugidx))

def turn_off(self, plugip, plugidx):
plug = self.plug_search(self._settings.get(["arrSmartplugs"]), "ip", plugip, "idx", plugidx)
Expand All @@ -372,25 +373,25 @@ def turn_off(self, plugip, plugidx):
webresponse = requests.get(backlog_url)
response = dict()
response["POWER%s" % plug["idx"]] = "OFF"

if plug["sysCmdOff"]:
self._tasmota_logger.debug(
"Running system command: %s in %s" % (plug["sysRunCmdOff"], plug["sysCmdOffDelay"]))
t = threading.Timer(int(plug["sysCmdOffDelay"]), os.system, args=[plug["sysRunCmdOff"]])
t.daemon = True
t.start()

if plug["autoDisconnect"] and self._printer.is_operational():
self._tasmota_logger.debug("Disconnnecting from printer")
self._printer.disconnect()
time.sleep(int(plug["autoDisconnectDelay"]))

if not plug["use_backlog"]:
self._tasmota_logger.debug("Not using backlog commands")
webresponse = requests.get(
"http://" + plug["ip"] + "/cm?user=" + plug["username"] + "&password=" + requests.utils.quote(
plug["password"]) + "&cmnd=Power" + str(plug["idx"]) + "%20off")
response = webresponse.json()
chk = response["POWER%s" % plug["idx"]]
if chk.upper() == "OFF":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="off",ip=plugip,idx=plugidx))
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plug["ip"], exc_info=True)
response = "Unknown error turning off %s index %s." % (plugip, plugidx)
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 = "0.8.16"
plugin_version = "0.8.17rc1"

# 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 95648d7

Please sign in to comment.