Skip to content

Commit

Permalink
1.0.1 (#126)
Browse files Browse the repository at this point in the history
* fix regression related to special characters in passwords
* clear _autostart_file on print start to avoid re-printing canceled print on connecting to printer
* fix backlog off command using backlog on delay
  • Loading branch information
jneilliii authored Jan 30, 2021
1 parent 2e1acc8 commit 0a608d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,10 @@ Once installed go into settings and enter the ip address for your TP-Link Smartp
With these options the raspberry pi will be shutdown 5 seconds after the idle timeout is reached (as configured on the main settings page) and send a backlog command to your Tasmota device to power off after a 60 second delay.

## Most recent changelog
**[1.0.0](https://github.com/jneilliii/OctoPrint-Tasmota/releases/tag/1.0.0)** (01/24/2021)
* jump to major version
* add additional logging during check status, to aid in debugging
* set _autostart_file None if print canceled or completed to prevent restarting file on connect
* add baudrate to printer connection command
* fix invalid state in confirmation prompt
* switch to using params in requests.get
* move check statuses to onAllBound to avoid potential lock up of UI load
* fix date format for graphing data
* add css error highlighting and disable update button on graph tab when inputs are invalid
* remove redundant css properties
* add cost to settings and graphing
* add connect event monitoring
**[1.0.1](https://github.com/jneilliii/OctoPrint-Tasmota/releases/tag/1.0.1)** (01/30/2021)
* fix regression related to special characters in passwords
* clear _autostart_file on print start to avoid re-printing canceled print on connecting to printer
* fix backlog off command using backlog on delay

### [All releases](https://github.com/jneilliii/OctoPrint-Tasmota/releases)

Expand Down
21 changes: 12 additions & 9 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ def on_event(self, event, payload):
self.print_job_power -= float(self.deep_get(status, ["energy_data", "Total"], default=0))
self._tasmota_logger.debug(self.print_job_power)

if event == Events.PRINT_STARTED:
self._autostart_file = None

if event == Events.PRINT_STARTED and self.powerOffWhenIdle:
if self._abort_timer is not None:
self._abort_timer.cancel()
Expand Down Expand Up @@ -416,11 +419,11 @@ def turn_on(self, plugip, plugidx):
try:
if plug["use_backlog"] and int(plug["backlog_on_delay"]) > 0:
backlog_command = "backlog delay {};Power{} on;".format(int(plug["backlog_on_delay"]) * 10, plug["idx"])
requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": backlog_command}, timeout=3)
requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": backlog_command}, timeout=3)
response = dict()
response["POWER%s" % plug["idx"]] = "ON"
else:
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": "Power{} on".format(plug["idx"])}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": "Power{} on".format(plug["idx"])}, timeout=3)
response = webresponse.json()
chk = response["POWER%s" % plug["idx"]]
except:
Expand Down Expand Up @@ -455,8 +458,8 @@ def turn_off(self, plugip, plugidx):
if plug["use_backlog"] and int(plug["backlog_off_delay"]) > 0:
self._tasmota_logger.debug(
"Using backlog commands with a delay value of %s" % str(int(plug["backlog_off_delay"]) * 10))
backlog_command = "backlog delay {};Power{} off;".format(int(plug["backlog_on_delay"]) * 10, plug["idx"])
requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": backlog_command}, timeout=3)
backlog_command = "backlog delay {};Power{} off;".format(int(plug["backlog_off_delay"]) * 10, plug["idx"])
requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": backlog_command}, timeout=3)
response = dict()
response["POWER%s" % plug["idx"]] = "OFF"
if plug["sysCmdOff"]:
Expand All @@ -471,7 +474,7 @@ def turn_off(self, plugip, plugidx):
time.sleep(int(plug["autoDisconnectDelay"]))
if not plug["use_backlog"]:
self._tasmota_logger.debug("Not using backlog commands")
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": "Power{} off".format(plug["idx"])}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": "Power{} off".format(plug["idx"])}, timeout=3)
response = webresponse.json()
chk = response["POWER%s" % plug["idx"]]
if chk.upper() == "OFF":
Expand All @@ -492,7 +495,7 @@ def check_status(self, plugip, plugidx):
try:
plug = self.plug_search(self._settings.get(["arrSmartplugs"]), "ip", plugip, "idx", plugidx)
self._tasmota_logger.debug(plug)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": "Status 0"}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": plug["username"], "password": plug["password"], "cmnd": "Status 0"}, timeout=3)
self._tasmota_logger.debug("check status code: {}".format(webresponse.status_code))
self._tasmota_logger.debug("check status text: {}".format(webresponse.text))
response = webresponse.json()
Expand Down Expand Up @@ -552,13 +555,13 @@ def check_status(self, plugip, plugidx):
return response

def checkSetOption26(self, plugip, username, password):
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": username, "password": requests.utils.quote(password), "cmnd": "SetOption26"}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": username, "password": password, "cmnd": "SetOption26"}, timeout=3)
response = webresponse.json()
self._tasmota_logger.debug(response)
return response

def setSetOption26(self, plugip, username, password):
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": username, "password": requests.utils.quote(password), "cmnd": "SetOption26 ON"}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plugip), params={"user": username, "password": password, "cmnd": "SetOption26 ON"}, timeout=3)
response = webresponse.json()
self._tasmota_logger.debug(response)
return response
Expand Down Expand Up @@ -607,7 +610,7 @@ def on_api_command(self, command, data):
self._timeout_value = None
for plug in self._settings.get(["arrSmartplugs"]):
if plug["use_backlog"] and int(plug["backlog_off_delay"]) > 0:
webresponse = requests.get("http://{}/cm".format(plug["ip"]), params={"user": plug["username"], "password": requests.utils.quote(plug["password"]), "cmnd": "backlog"}, timeout=3)
webresponse = requests.get("http://{}/cm".format(plug["ip"]), params={"user": plug["username"], "password": plug["password"], "cmnd": "backlog"}, timeout=3)
self._tasmota_logger.debug("Cleared countdown rules for %s" % plug["ip"])
self._tasmota_logger.debug(webresponse)
self._tasmota_logger.debug("Power off aborted.")
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.0"
plugin_version = "1.0.1"

# 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 0a608d2

Please sign in to comment.