Skip to content

Commit 1cecbda

Browse files
authored
0.9.26 (#224)
* add uptime check to verify system uptime is not below our timeout threshold * fix issues related to uptime comparison on startup * fix powering on during startup when doing a cold boot
1 parent 485ff1d commit 1cecbda

File tree

5 files changed

+31
-219
lines changed

5 files changed

+31
-219
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ Once installed go into settings and enter the ip address for your TP-Link Smartp
5656
- **Run System Command Before Off**
5757
- When checked will run system command configured in **System Command Off** setting after a delay in seconds configured in **System Command Off Delay**.
5858

59+
## Most recent changelog
60+
61+
**[0.9.26](https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/releases/tag/0.9.26)** (11/20/2020)
62+
63+
* add uptime check to verify system uptime is not below our timeout threshold
64+
* fix issues related to uptime comparison on startup
65+
* fix powering on during startup when doing a cold boot
66+
67+
68+
### [All releases](https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/releases)
69+
5970
## Get Help
6071

6172
If you experience issues with this plugin or need assistance please use the issue tracker by clicking issues above.

changelog.md

Lines changed: 0 additions & 216 deletions
This file was deleted.

octoprint_tplinksmartplug/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import time
1717
import sqlite3
1818
import decimal
19+
from uptime import uptime
1920
from datetime import datetime
2021
from struct import unpack
2122
from builtins import bytes
@@ -142,7 +143,16 @@ def on_after_startup(self):
142143
self._tplinksmartplug_logger.debug("idleIgnoreCommands: %s" % self.idleIgnoreCommands)
143144
self.idleTimeoutWaitTemp = self._settings.get_int(["idleTimeoutWaitTemp"])
144145
self._tplinksmartplug_logger.debug("idleTimeoutWaitTemp: %s" % self.idleTimeoutWaitTemp)
145-
146+
if self._settings.get_boolean(["event_on_startup_monitoring"]) is True:
147+
self._tplinksmartplug_logger.debug("powering on due to startup.")
148+
for plug in self._settings.get(['arrSmartplugs']):
149+
if plug["event_on_startup"] is True:
150+
self._tplinksmartplug_logger.debug("powering on %s due to startup." % (plug["ip"]))
151+
response = self.turn_on(plug["ip"])
152+
if response.get("currentState", False) == "on":
153+
self._plugin_manager.send_plugin_message(self._identifier, response)
154+
else:
155+
self._tplinksmartplug_logger.debug("powering on %s during startup failed." % (plug["ip"]))
146156
self._reset_idle_timer()
147157

148158
##~~ SettingsPlugin mixin
@@ -731,6 +741,12 @@ def _idle_poweroff(self):
731741
if self._printer.is_printing() or self._printer.is_paused():
732742
return
733743

744+
if (uptime()/60) <= (self._settings.get_int(["idleTimeout"])):
745+
self._tplinksmartplug_logger.debug("Just booted so wait for time sync.")
746+
self._tplinksmartplug_logger.debug("uptime: {}, comparison: {}".format((uptime()/60), (self._settings.get_int(["idleTimeout"]))))
747+
self._reset_idle_timer()
748+
return
749+
734750
self._tplinksmartplug_logger.debug(
735751
"Idle timeout reached after %s minute(s). Turning heaters off prior to powering off plugs." % self.idleTimeout)
736752
if self._wait_for_heaters():

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
###
88

99
.
10+
uptime

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "OctoPrint-TPLinkSmartplug"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "0.9.25"
17+
plugin_version = "0.9.26"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module
@@ -33,7 +33,7 @@
3333
plugin_license = "AGPLv3"
3434

3535
# Any additional requirements besides OctoPrint should be listed here
36-
plugin_requires = []
36+
plugin_requires = ["uptime"]
3737

3838
### --------------------------------------------------------------------------------------------------------------------
3939
### More advanced options that you usually shouldn't have to touch follow after this point

0 commit comments

Comments
 (0)