From b745da46daa833a11aa693252adf203166191caa Mon Sep 17 00:00:00 2001 From: jneilliii Date: Sat, 1 May 2021 14:40:38 -0400 Subject: [PATCH] add numeric StatusSTS messages for chk values, #150 --- octoprint_tasmota/__init__.py | 10 +++++----- setup.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/octoprint_tasmota/__init__.py b/octoprint_tasmota/__init__.py index 3dbb460..d224460 100644 --- a/octoprint_tasmota/__init__.py +++ b/octoprint_tasmota/__init__.py @@ -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, @@ -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) @@ -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) diff --git a/setup.py b/setup.py index 6a543d3..861618a 100644 --- a/setup.py +++ b/setup.py @@ -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