Skip to content

Commit

Permalink
Updated to Python 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Lamoureux committed May 1, 2022
1 parent 9e0b8ab commit 6c4501a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions August Home.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>1.0.20</string>
<string>1.1.0</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<string>3.0</string>
<key>IwsApiVersion</key>
<string>1.0.0</string>
<key>CFBundleDisplayName</key>
Expand Down
96 changes: 48 additions & 48 deletions August Home.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs):

########################################
def startup(self):
self.debugLog(u"startup called")
self.debugLog("startup called")

if self.configStatus:
if self.debug:
Expand All @@ -110,7 +110,7 @@ def configureDoorbells(self):
self.doorbell_list = []

if self.has_doorbell:
for key, value in db_list.items():
for key, value in list(db_list.items()):

self.doorbell_list.append((key, value["name"]))
self.logger.debug("Added doorbell " + value["name"] + " with ID " + key)
Expand Down Expand Up @@ -161,10 +161,10 @@ def version_check(self):
)
)
except Exception as exc:
self.logger.error(unicode(exc))
self.logger.error(str(exc))

def shutdown(self):
self.debugLog(u"shutdown called")
self.debugLog("shutdown called")

def runConcurrentThread(self):
self.logger.debug("Starting concurrent tread")
Expand Down Expand Up @@ -239,7 +239,7 @@ def resetHouseList(self):
# UI settings dialog has been validated. This is a good place to force any properties
# we need the device to have, and to cleanup old properties.
def deviceStartComm(self, dev):
self.debugLog(u"deviceStartComm: %s" % (dev.name,))
self.debugLog("deviceStartComm: %s" % (dev.name,))
props = dev.pluginProps

if dev.deviceTypeId == "augLock":
Expand Down Expand Up @@ -273,7 +273,7 @@ def deviceStartComm(self, dev):
props["houseName"] = house["HouseName"]

batteryLevel = int(100*house["battery"])
batteryLevelStr = u"%d%%" % (int(batteryLevel))
batteryLevelStr = "%d%%" % (int(batteryLevel))
props["batteryLevel"] = batteryLevel
props["batteryLevelStr"] = batteryLevelStr

Expand Down Expand Up @@ -328,9 +328,9 @@ def actionControlDevice(self, action, dev):
if serverState is not None:
if dev.onState != serverState:
if serverState:
indigo.server.log(u"received \"" + dev.name + "\" was locked")
indigo.server.log("received \"" + dev.name + "\" was locked")
else:
indigo.server.log(u"received \"" + dev.name + "\" was unlocked")
indigo.server.log("received \"" + dev.name + "\" was unlocked")

dev.updateStateOnServer('onOffState', value=serverState)
self.logger.error("The state of the lock in Indigo was out of sync, " + dev.name + " was already " + actionstr + "ed")
Expand All @@ -341,13 +341,13 @@ def actionControlDevice(self, action, dev):
return

# Command hardware module (dev) to LOCK here:
indigo.server.log(u"sending \"%s\" %s" % (dev.name, actionstr))
indigo.server.log("sending \"%s\" %s" % (dev.name, actionstr))

sendSuccess = self.sendCommand(dev.pluginProps["lockID"], actionstr)

if sendSuccess:
# If success then log that the command was successfully sent.
indigo.server.log(u"sent \"%s\" %s" % (dev.name, actionstr))
indigo.server.log("sent \"%s\" %s" % (dev.name, actionstr))

# Update a timestamp of the last time the device was updated by Indigo
dev.updateStateOnServer("lastSentIndigoUpdateTime", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
Expand All @@ -360,7 +360,7 @@ def actionControlDevice(self, action, dev):

else:
# Else log failure but do NOT update state on Indigo Server.
self.logger.error(u"send \"%s\" %s failed" % (dev.name, actionstr))
self.logger.error("send \"%s\" %s failed" % (dev.name, actionstr))

self.updateVariables()

Expand All @@ -376,22 +376,22 @@ def actionControlUniversal(self, action, dev):
self.wakeup(doorbellID)


indigo.server.log(u"sent \"%s\" %s" % (dev.name, "status request"))
indigo.server.log("sent \"%s\" %s" % (dev.name, "status request"))

lockDetails = self.getLockDetails(dev.pluginProps["lockID"])

serverState = lockDetails["LockStatus"]["status"] == "locked"

batteryLevel = int(100*lockDetails["battery"])
batteryLevelStr = u"%d%%" % (int(batteryLevel))
batteryLevelStr = "%d%%" % (int(batteryLevel))
dev.updateStateOnServer('batteryLevel', batteryLevel, uiValue=batteryLevelStr)

if serverState is not None:
if dev.onState != serverState:
if serverState:
indigo.server.log(u"received \"" + dev.name + "\" was locked")
indigo.server.log("received \"" + dev.name + "\" was locked")
else:
indigo.server.log(u"received \"" + dev.name + "\" was unlocked")
indigo.server.log("received \"" + dev.name + "\" was unlocked")

dev.updateStateOnServer('onOffState', value=serverState)

Expand All @@ -406,9 +406,9 @@ def actionControlUniversal(self, action, dev):
if serverState is not None:
if dev.onState != serverState:
if serverState:
indigo.server.log(u"received \"" + dev.name + "\" was opened")
indigo.server.log("received \"" + dev.name + "\" was opened")
else:
indigo.server.log(u"received \"" + dev.name + "\" was closed")
indigo.server.log("received \"" + dev.name + "\" was closed")

dev.updateStateOnServer('onOffState', value=serverState)
else:
Expand Down Expand Up @@ -474,10 +474,10 @@ def validatePhone(self, login, code):
"code": code
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
print(('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code)))
print(('Response HTTP Response Body: {content}'.format(
content=response.content)))
except requests.exceptions.RequestException:
print('HTTP Request failed')

Expand All @@ -503,10 +503,10 @@ def validateEmail(self, login, code):
"code": code
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
print(('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code)))
print(('Response HTTP Response Body: {content}'.format(
content=response.content)))
except requests.exceptions.RequestException:
print('HTTP Request failed')

Expand All @@ -529,10 +529,10 @@ def sendPhoneValidation(self, login):
"value": login
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
print(('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code)))
print(('Response HTTP Response Body: {content}'.format(
content=response.content)))
except requests.exceptions.RequestException:
print('HTTP Request failed')

Expand All @@ -557,10 +557,10 @@ def sendEmailValidation(self, login):
"value": login
})
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
print(('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code)))
print(('Response HTTP Response Body: {content}'.format(
content=response.content)))
except requests.exceptions.RequestException:
print('HTTP Request failed')

Expand Down Expand Up @@ -859,7 +859,7 @@ def availableLinklocks(self, filter="", valuesDict=None, typeId="", targetId=0):
locks_list.append((-1, "none"))
return locks_list

def myLocks(self, filter=u'', valuesDict=None, typeId=u'', targetId=0):
def myLocks(self, filter='', valuesDict=None, typeId='', targetId=0):
myLocks = []
for lock in [s for s in indigo.devices.iter(filter="self.augLock") if s.enabled]:
value = lock.id
Expand All @@ -876,7 +876,7 @@ def availableLocks(self, filter="", valuesDict=None, typeId="", targetId=0):
dev = indigo.devices.get(targetId, None)

if self.configStatus:
for key, value in locks.items():
for key, value in list(locks.items()):
found = False
for existing_dev in [s for s in indigo.devices.iter(filter="self") if s.enabled and s.deviceTypeId == "augLock"]:
if key == existing_dev.pluginProps["lockID"]:
Expand Down Expand Up @@ -1054,7 +1054,7 @@ def update_all_from_august_activity_log(self):
extraText = " (this event was delayed in the August activity log, so the Indigo lock state had already been updated.)"

if activityItem.action == "onetouchlock":
indigo.server.log(u"received \"" + dev.name + "\" was One-Touch Locked at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)
indigo.server.log("received \"" + dev.name + "\" was One-Touch Locked at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)
elif activityItem.action == "doorclosed" or activityItem.action == "dooropen":

# Update the state of the DoorSense Lock if it's set up.
Expand All @@ -1065,19 +1065,19 @@ def update_all_from_august_activity_log(self):
break

if activityItem.action == "doorclosed":
indigo.server.log(u"received \"" + dev.name + "\" door was closed at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) ")
indigo.server.log("received \"" + dev.name + "\" door was closed at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) ")
else:
indigo.server.log(u"received \"" + dev.name + "\" door was opened at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) ")
indigo.server.log("received \"" + dev.name + "\" door was opened at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) ")

elif activityItem.callingUser == "by Auto Relock":
indigo.server.log(u"received \"" + dev.name + "\" was Auto-Locked at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")
indigo.server.log("received \"" + dev.name + "\" was Auto-Locked at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")
elif activityItem.action == "addedpin" or activityItem.action == "removedpined":
indigo.server.log(u"received \"" + dev.name + "\" PIN Code was added or removed for a user (ignored).")
indigo.server.log("received \"" + dev.name + "\" PIN Code was added or removed for a user (ignored).")
break
elif activityItem.via == "via ZWave":
indigo.server.log(u"received \"" + dev.name + "\" was " + activityItem.action + "ed at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)
indigo.server.log("received \"" + dev.name + "\" was " + activityItem.action + "ed at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)
else:
indigo.server.log(u"received \"" + dev.name + "\" was " + activityItem.action + "ed " + activityItem.callingUser + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)
indigo.server.log("received \"" + dev.name + "\" was " + activityItem.action + "ed " + activityItem.callingUser + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago) " + activityItem.via + extraText)

if dev.onState != activityItem.onState():
dev.updateStateOnServer('onOffState', value=activityItem.onState())
Expand Down Expand Up @@ -1139,9 +1139,9 @@ def update_all_from_august_activity_log(self):
self.last_doorbell_motion = datetime.datetime.now()

if activityItem.action == "doorbell_call_missed":
indigo.server.log(u"received missed doorbell call at " + activityItem.deviceName + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")
indigo.server.log("received missed doorbell call at " + activityItem.deviceName + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")
elif activityItem.action == "doorbell_motion_detected":
indigo.server.log(u"received motion detected event at " + activityItem.deviceName + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")
indigo.server.log("received motion detected event at " + activityItem.deviceName + " at " + activityItem.dateTime.strftime("%Y-%m-%d %H:%M:%S") + " (" + str(int(delta_time.total_seconds())) + " seconds ago)")

# PROCESS DOORBELL TRIGGERS
for trigger in indigo.triggers.iter("self.doorbellMotion"):
Expand Down Expand Up @@ -1193,9 +1193,9 @@ def update_all_from_august(self):
if dev.onState != serverState:

if serverState:
indigo.server.log(u"received \"" + dev.name + "\" was locked")
indigo.server.log("received \"" + dev.name + "\" was locked")
else:
indigo.server.log(u"received \"" + dev.name + "\" was unlocked")
indigo.server.log("received \"" + dev.name + "\" was unlocked")

dev.updateStateOnServer('onOffState', value=serverState)

Expand Down Expand Up @@ -1226,7 +1226,7 @@ def closedPrefsConfigUi(self, valuesDict, userCancelled):
self.debug = valuesDict["chkDebug"]
self.debug_L2= valuesDict["chkDebug_L2"]

self.createVariableFolder(valuesDict[u"indigoVariablesFolderName"])
self.createVariableFolder(valuesDict["indigoVariablesFolderName"])


def createVariableFolder(self, variableFolderName):
Expand All @@ -1239,7 +1239,7 @@ def createVariableFolder(self, variableFolderName):

if self.indigoVariablesFolderName not in indigo.variables.folders:
self.indigoVariablesFolderID = indigo.variables.folder.create(self.indigoVariablesFolderName).id
indigo.server.log(self.indigoVariablesFolderName+ u" folder created")
indigo.server.log(self.indigoVariablesFolderName+ " folder created")
else:
self.indigoVariablesFolderID=indigo.variables.folders[self.indigoVariablesFolderName].id

Expand Down

0 comments on commit 6c4501a

Please sign in to comment.