Skip to content

Commit

Permalink
0.9.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Feb 17, 2019
1 parent bbb1df3 commit de1dd6b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
14 changes: 12 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.9.13] - 2019-02-16
### Fixed
- Update button state when plug powered on/off via gcode.

## [0.9.12] - 2019-02-10
### Fixed
- Issue introduced in previous version prevented fresh installs from working properly.

## [0.9.11] - 2019-02-09
### Fixed
- Energy monitoring sidebar not displaying consistently.
Expand Down Expand Up @@ -158,8 +166,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial release.

[0.9.9]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.11
[0.9.9]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.10
[0.9.13]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.13
[0.9.12]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.12
[0.9.11]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.11
[0.9.10]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.10
[0.9.9]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.9
[0.9.8]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.8
[0.9.7]: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/tree/0.9.7
Expand Down
30 changes: 19 additions & 11 deletions octoprint_tplinksmartplug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from datetime import datetime

class tplinksmartplugPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.StartupPlugin,
octoprint.plugin.ProgressPlugin):
Expand Down Expand Up @@ -45,7 +45,7 @@ def on_after_startup(self):
def get_settings_defaults(self):
return dict(
debug_logging = False,
arrSmartplugs = [{'ip':'','label':'','icon':'icon-bolt','displayWarning':True,'warnPrinting':False,'gcodeEnabled':False,'gcodeOnDelay':0,'gcodeOffDelay':0,'autoConnect':True,'autoConnectDelay':10.0,'autoDisconnect':True,'autoDisconnectDelay':0,'sysCmdOn':False,'sysRunCmdOn':'','sysCmdOnDelay':0,'sysCmdOff':False,'sysRunCmdOff':'','sysCmdOffDelay':0,'currentState':'unknown','btnColor':'#808080','useCountdownRules':False,'countdownOnDelay':0,'countdownOffDelay':0,'emeter':None}],
arrSmartplugs = [{'ip':'','label':'','icon':'icon-bolt','displayWarning':True,'warnPrinting':False,'gcodeEnabled':False,'gcodeOnDelay':0,'gcodeOffDelay':0,'autoConnect':True,'autoConnectDelay':10.0,'autoDisconnect':True,'autoDisconnectDelay':0,'sysCmdOn':False,'sysRunCmdOn':'','sysCmdOnDelay':0,'sysCmdOff':False,'sysRunCmdOff':'','sysCmdOffDelay':0,'currentState':'unknown','btnColor':'#808080','useCountdownRules':False,'countdownOnDelay':0,'countdownOffDelay':0,'emeter':{'get_realtime':{}}}],
pollingInterval = 15,
pollingEnabled = False
)
Expand Down Expand Up @@ -168,15 +168,18 @@ def turn_off(self, plugip):
def check_status(self, plugip):
self._tplinksmartplug_logger.debug("Checking status of %s." % plugip)
if plugip != "":
emeter_data = None
today = datetime.today()
check_status_cmnd = '{"system":{"get_sysinfo":{}},"emeter":{"get_realtime":{}}}'
check_status_cmnd = '{"system":{"get_sysinfo":{}}}'
# ,"get_daystat":{"month":%d,"year":%d}}}' % (today.month, today.year)
# ,"emeter":{"get_realtime":{}}
self._tplinksmartplug_logger.debug(check_status_cmnd)
response = self.sendCommand(check_status_cmnd, plugip)
if self.lookup(response, *["emeter","get_realtime"]):
emeter_data = response["emeter"]
else:
emeter_data = None

if "ENE" in self.lookup(response, *["system","get_sysinfo","feature"]):
check_emeter_data = self.sendCommand('{"emeter":{"get_realtime":{}}}', plugip)
if self.lookup(check_emeter_data, *["emeter","get_realtime"]):
emeter_data = check_emeter_data["emeter"]

chk = self.lookup(response,*["system","get_sysinfo","relay_state"])
if chk == 1:
Expand Down Expand Up @@ -306,7 +309,12 @@ def gcode_turn_off(self, plug):
if plug["warnPrinting"] and self._printer.is_printing():
self._logger.info("Not powering off %s because printer is printing." % plug["label"])
else:
self.turn_off(plug["ip"])
chk = self.turn_off(plug["ip"])
self._plugin_manager.send_plugin_message(self._identifier, chk)

def gcode_turn_on(self, plug):
chk = self.turn_on(plug["ip"])
self._plugin_manager.send_plugin_message(self._identifier, chk)

def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
if gcode:
Expand All @@ -316,7 +324,7 @@ def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwar
plug = self.plug_search(self._settings.get(["arrSmartplugs"]),"ip",plugip)
self._tplinksmartplug_logger.debug(plug)
if plug["gcodeEnabled"]:
t = threading.Timer(int(plug["gcodeOnDelay"]),self.turn_on,args=[plugip])
t = threading.Timer(int(plug["gcodeOnDelay"]),self.gcode_turn_on,[plug])
t.start()
return
elif cmd.startswith("M81"):
Expand All @@ -337,7 +345,7 @@ def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwar
plug = self.plug_search(self._settings.get(["arrSmartplugs"]),"ip",plugip)
self._tplinksmartplug_logger.debug(plug)
if plug["gcodeEnabled"]:
t = threading.Timer(int(plug["gcodeOnDelay"]),self.turn_on,args=[plugip])
t = threading.Timer(int(plug["gcodeOnDelay"]),self.gcode_turn_on,[plug])
t.start()
return None
elif cmd.startswith("@TPLINKOFF"):
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-TPLinkSmartplug"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.9.11"
plugin_version = "0.9.13"

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

Please sign in to comment.