Skip to content

Commit

Permalink
0.8.7
Browse files Browse the repository at this point in the history
### Added
- Python 3 compatibility
### Fixed
- ON/OFF comparison in cases where the response is not uppercase by default
- Resolve issues with special characters in password
  • Loading branch information
jneilliii authored Oct 22, 2019
1 parent 1b8b068 commit 568eafd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ 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.8.7] - 2019-10-06
### Added
- Python 3 compatibility for future OctoPrint release.
### Fixed
- ON/OFF comparison in cases where the response is not uppercase by default.
- Resolve issues with special characters in passwords.

## [0.8.6] - 2019-08-11
### Added
- configurable color options for the navbar icons.
- countdown timer that utilizes the backlog command with delay to allow for powering off a plug after the pi has been shutdown using the system command option.
- polling option to check status based on configured interval.

## [0.8.5] - 2018-03-12
### Added
- Show label text when TouchUI interface is enabled. Default UI should not see any change.
Expand Down Expand Up @@ -81,6 +94,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial release.

[0.8.7]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.8.7
[0.8.6]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.8.6
[0.8.5]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.8.5
[0.8.4]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.8.4
[0.8.3]: https://github.com/jneilliii/OctoPrint-Tasmota/tree/0.8.3
Expand Down
32 changes: 16 additions & 16 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import octoprint.plugin
from octoprint.server import user_permission
import socket
import json
import time
import logging
import os
import re
import urllib2
import requests
import threading

class tasmotaPlugin(octoprint.plugin.SettingsPlugin,
Expand Down Expand Up @@ -94,12 +93,12 @@ def turn_on(self, plugip, plugidx, username="admin", password="", backlog_delay=
self._tasmota_logger.debug("Turning on %s index %s." % (plugip, plugidx))
try:
if int(backlog_delay) > 0:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=backlog%20delay%20" + str(int(backlog_delay)*10) + "%3BPower" + str(plugidx) + "%20on%3B").read()
webresponse = requests.get("http://" + plugip + "/cm?user=" + username + "&password=" + requests.utils.quote(password) + "&cmnd=backlog%20delay%20" + str(int(backlog_delay)*10) + "%3BPower" + str(plugidx) + "%20on%3B")
response = dict()
response["POWER%s" % plugidx] = "ON"
else:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx) + "%20on").read()
response = json.loads(webresponse)
webresponse = requests.get("http://" + plugip + "/cm?user=" + username + "&password=" + requests.utils.quote(password) + "&cmnd=Power" + str(plugidx) + "%20on")
response = webresponse.json()
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
Expand All @@ -109,9 +108,9 @@ def turn_on(self, plugip, plugidx, username="admin", password="", backlog_delay=
self._tasmota_logger.debug("Response: %s" % response)
if self._settings.get(['singleRelay']):
plugidx = '1'
if chk == "ON":
if chk.upper() == "ON":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="on",ip=plugip,idx=plugidx))
elif chk == "OFF":
elif chk.upper() == "OFF":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="off",ip=plugip,idx=plugidx))
else:
self._tasmota_logger.debug(response)
Expand All @@ -123,12 +122,12 @@ def turn_off(self, plugip, plugidx, username="admin", password="", backlog_delay
self._tasmota_logger.debug("Turning off %s index %s." % (plugip, plugidx))
try:
if int(backlog_delay) > 0:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=backlog%20delay%20" + str(int(backlog_delay)*10) + "%3BPower" + str(plugidx) + "%20off%3B").read()
webresponse = requests.get("http://" + plugip + "/cm?user=" + username + "&password=" + requests.utils.quote(password) + "&cmnd=backlog%20delay%20" + str(int(backlog_delay)*10) + "%3BPower" + str(plugidx) + "%20off%3B")
response = dict()
response["POWER%s" % plugidx] = "OFF"
else:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx) + "%20off").read()
response = json.loads(webresponse)
webresponse = requests.get("http://" + plugip + "/cm?user=" + username + "&password=" + requests.utils.quote(password) + "&cmnd=Power" + str(plugidx) + "%20off")
response = webresponse.json()
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
Expand All @@ -138,9 +137,9 @@ def turn_off(self, plugip, plugidx, username="admin", password="", backlog_delay
self._tasmota_logger.debug("Response: %s" % response)
if self._settings.get(['singleRelay']):
plugidx = '1'
if chk == "ON":
if chk.upper() == "ON":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="on",ip=plugip,idx=plugidx))
elif chk == "OFF":
elif chk.upper() == "OFF":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="off",ip=plugip,idx=plugidx))
else:
self._tasmota_logger.debug(response)
Expand All @@ -152,9 +151,9 @@ def check_status(self, plugip, plugidx, username="admin", password=""):
self._tasmota_logger.debug("Checking status of %s index %s." % (plugip, plugidx))
if plugip != "":
try:
webresponse = urllib2.urlopen("http://" + plugip + "/cm?user=" + username + "&password=" + password + "&cmnd=Power" + str(plugidx)).read()
webresponse = requests.get("http://" + plugip + "/cm?user=" + username + "&password=" + requests.utils.quote(password) + "&cmnd=Power" + str(plugidx))
self._tasmota_logger.debug("%s index %s response: %s" % (plugip, plugidx, webresponse))
response = json.loads(webresponse)
response = webresponse.json()
chk = response["POWER%s" % plugidx]
except:
self._tasmota_logger.error('Invalid ip or unknown error connecting to %s.' % plugip, exc_info=True)
Expand All @@ -164,9 +163,9 @@ def check_status(self, plugip, plugidx, username="admin", password=""):
self._tasmota_logger.debug("%s index %s is %s" % (plugip, plugidx, chk))
if self._settings.get(['singleRelay']):
plugidx = '1'
if chk == "ON":
if chk.upper() == "ON":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="on",ip=plugip,idx=plugidx))
elif chk == "OFF":
elif chk.upper() == "OFF":
self._plugin_manager.send_plugin_message(self._identifier, dict(currentState="off",ip=plugip,idx=plugidx))
else:
self._tasmota_logger.debug(response)
Expand Down Expand Up @@ -266,6 +265,7 @@ def get_update_information(self):
# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
# can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
__plugin_name__ = "Tasmota"
__plugin_pythoncompat__ = ">=2.7,<4"

def __plugin_load__():
global __plugin_implementation__
Expand Down
2 changes: 1 addition & 1 deletion octoprint_tasmota/static/js/tasmota.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ $(function() {
console.log('plug data:'+ko.toJSON(plug));
}

if (plug.currentState != data.currentState) {
if (plug.currentState != data.currentState) {
plug.currentState(data.currentState)
switch(data.currentState) {
case "on":
Expand Down
4 changes: 2 additions & 2 deletions 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.8.6"
plugin_version = "0.8.7"

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

# Any additional requirements besides OctoPrint should be listed here
plugin_requires = []
plugin_requires = ["requests"]

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

0 comments on commit 568eafd

Please sign in to comment.