Skip to content

Commit

Permalink
add numeric StatusSTS messages for chk values, #150
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed May 1, 2021
1 parent cc8bb4d commit b745da4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def turn_on(self, plugip, plugidx):

self._tasmota_logger.debug("Response: %s" % response)

if chk.upper() == "ON":
if chk.upper() in ["ON", "1"]:
if plug["autoConnect"] and self._printer.is_closed_or_error():
self._logger.info(self._settings.global_get(['serial']))
c = threading.Timer(int(plug["autoConnectDelay"]), self._printer.connect,
Expand Down Expand Up @@ -495,8 +495,8 @@ def turn_off(self, plugip, plugidx):
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": "Power{} off".format(plug["idx"])}, timeout=self._settings.get_int(["request_timeout"]))
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))
if chk.upper() in ["OFF", "0"]:
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 Expand Up @@ -561,9 +561,9 @@ def check_status(self, plugip, plugidx):
sensor_data = None

self._tasmota_logger.debug("%s index %s is %s" % (plugip, plugidx, chk))
if chk.upper() == "ON":
if chk.upper() in ["ON", "1"]:
response = {"currentState": "on", "ip": plugip, "idx": plugidx, "energy_data": energy_data, "sensor_data": sensor_data}
elif chk.upper() == "OFF":
elif chk.upper() in ["OFF", "0"]:
response = {"currentState": "off", "ip": plugip, "idx": plugidx, "energy_data": energy_data, "sensor_data": sensor_data}
else:
self._tasmota_logger.debug(response)
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.0.4rc2"
plugin_version = "1.0.4rc3"

# 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 b745da4

Please sign in to comment.