Skip to content

Commit

Permalink
Merge pull request #12 from jneilliii/dev
Browse files Browse the repository at this point in the history
0.3.0
  • Loading branch information
jneilliii authored Jan 4, 2018
2 parents 204a86d + 0ae7a3e commit c97c6cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.3.0] - 2018-01-04
### Fixed
- multiple relays not being detected properly

## [0.2.0] - 2017-12-03
### Added
- tasmota authentication when password is configured in the device's configuration other section.
Expand All @@ -17,5 +21,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial release.

[0.3.0]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.3.0
[0.2.0]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.2.0
[0.1.0]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.1.0
13 changes: 6 additions & 7 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def turn_on(self, plugip, plugidx, username="admin", password=""):
try:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx) + "%20on").read()
response = json.loads(webresponse.split()[2])
chk = response["POWER"]
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
response = "Unknown error turning on %s index %s." % (plugip, plugidx)
Expand All @@ -109,7 +109,7 @@ def turn_off(self, plugip, plugidx, username="admin", password=""):
try:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx) + "%20off").read()
response = json.loads(webresponse.split()[2])
chk = response["POWER"]
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
response = "Unknown error turning off %s index %s." % (plugip, plugidx)
Expand All @@ -132,7 +132,7 @@ def check_status(self, plugip, plugidx, username="admin", password=""):
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx)).read()
self._tasmota_logger.debug("%s index %s response: %s" % (plugip, plugidx, webresponse))
response = json.loads(webresponse.split()[2])
chk = response["POWER"]
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
response = "unknown error with %s." % plugip
Expand Down Expand Up @@ -194,14 +194,13 @@ def processGCODE(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwar
plugidx = cmd.split()[2]
if cmd.startswith("M80"):
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="unknown",gcodeon=True,ip=plugip,idx=plugidx))
self._tasmota_logger.debug("Received M80 command, attempting power on.")
self._tasmota_logger.debug("Received M80 command, attempting power on of %s index %s." % (plugip,plugidx))
return
elif cmd.startswith("M81"):
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="unknown",gcodeoff=True,ip=plugip,idx=plugidx))
self._tasmota_logger.debug("Received M81 command, attempting power off.")
return
else:
self._tasmota_logger.debug("Received M81 command, attempting power off of %s index %s." % (plugip,plugidx))
return
return


##~~ Softwareupdate hook
Expand Down
9 changes: 5 additions & 4 deletions octoprint_tasmota/static/js/tasmota.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,21 @@ $(function() {
}

plug = ko.utils.arrayFirst(self.settings.settings.plugins.tasmota.arrSmartplugs(),function(item){
return (item.ip() == data.ip) && (item.idx() == data.idx);
}) || {'ip':data.ip,'idx':data.idx,'currentState':'unknown','btnColor':'#808080'};
return ((item.ip().toUpperCase() == data.ip.toUpperCase()) && (item.idx() == data.idx));
}) || {'ip':data.ip,'idx':data.idx,'currentState':'unknown','btnColor':'#808080','gcodeEnabled':false};

if(self.settings.settings.plugins.tasmota.debug_logging()){
console.log(self.settings.settings.plugins.tasmota.arrSmartplugs());
console.log('msg received:'+JSON.stringify(data));
console.log('plug data:'+ko.toJSON(plug));
}

if (data.gcodeon && plug.gcodeEnabled()) {
if (data.gcodeon && plug.gcodeEnabled) {
setTimeout(function(){self.turnOn(plug)},plug.gcodeOnDelay()*1000);
return false;
}

if (data.gcodeoff && plug.gcodeEnabled()) {
if (data.gcodeoff && plug.gcodeEnabled) {
setTimeout(function(){self.turnOff(plug)},plug.gcodeOffDelay()*1000);
return false;
}
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 = "0.2.0"
plugin_version = "0.3.0"

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

Please sign in to comment.