Skip to content

Commit

Permalink
Widens coverage to include additional API constructions. Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveL17 committed Dec 7, 2019
1 parent 9d78a45 commit 3e9bf3a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion GhostXML.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.4.39</string>
<string>0.4.40</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
16 changes: 12 additions & 4 deletions GhostXML.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"""

# TODO: Additional auth types: Oauth2, WSSE
# TODO: when device name is changed, it doesn't get updated in the plugin.
# TODO: phony IP device doesn't show offline in UI. Look at "no data to return" in code. Note that this was not tested on LAN.

# ================================Stock Imports================================
# import datetime
Expand Down Expand Up @@ -40,7 +42,7 @@
__copyright__ = u"There is no copyright for the GhostXML code base."
__license__ = u"MIT"
__title__ = u"GhostXML Plugin for Indigo Home Control"
__version__ = u"0.4.39"
__version__ = u"0.4.40"

# Establish default plugin prefs; create them if they don't already exist.
kDefaultPluginPrefs = {
Expand Down Expand Up @@ -254,7 +256,7 @@ def getDeviceStateList(self, dev):

return state_list

# =============================================================================
# =============================================================================
def runConcurrentThread(self):

# This sleep will execute only when the plugin is started/restarted. It gives
Expand Down Expand Up @@ -338,7 +340,6 @@ def validateDeviceConfigUi(self, valuesDict, typeID, devId):
url = valuesDict['sourceXML']
url_list = ('file:///', 'http://', 'https://')
use_digest = valuesDict['useDigest']
valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;="
var_list = [var.id for var in indigo.variables]

try:
Expand Down Expand Up @@ -821,7 +822,7 @@ def clean_the_keys(self, input_data):
# simply deleting them could cause problems. Add additional k/v pairs to
# chars_to_replace as needed.

chars_to_replace = {'_ghostxml_': '_', '+': '_plus_', '-': '_minus_', 'true': 'True', 'false': 'False', ' ': '_'}
chars_to_replace = {'_ghostxml_': '_', '+': '_plus_', '-': '_minus_', 'true': 'True', 'false': 'False', ' ': '_', ':': '_colon_', '.': '_dot_'}
chars_to_replace = dict((re.escape(k), v) for k, v in chars_to_replace.iteritems())
pattern = re.compile("|".join(chars_to_replace.keys()))

Expand Down Expand Up @@ -963,6 +964,8 @@ def refresh_data_for_dev(self, dev):

if dev.configured and dev.enabled:

self.host_plugin.logger.info(u"{0}".format(dev.name))

# Get the data.
self.rawData = self.get_the_data(dev)

Expand Down Expand Up @@ -999,6 +1002,11 @@ def refresh_data_for_dev(self, dev):
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Error')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorTripped)
self.bad_calls += 1
# 2019-11-23 DaveL17 Added additional condition where device should be marked as offline.
elif dev.states.get("Response", "") == "No data to return.":
dev.updateStateOnServer('deviceIsOnline', value=False, uiValue='Error')
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorTripped)
self.bad_calls += 1
else:
dev.updateStateOnServer('deviceIsOnline', value=True, uiValue="Updated")
dev.updateStateImageOnServer(indigo.kStateImageSel.SensorOn)
Expand Down
4 changes: 4 additions & 0 deletions _changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
GhostXML Change Log

v0.4.40
- Widens coverage to include additional API constructions.
- Code cleanup.

v0.4.39
- Initial deprecation of the stop_sleep() method (unused).

Expand Down

0 comments on commit 3e9bf3a

Please sign in to comment.