Skip to content

Commit

Permalink
unicode fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingDiver committed Mar 24, 2018
1 parent 401a209 commit 724ca23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Alexa-Hue Bridge.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>3.0.28</string>
<string>3.0.29</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
54 changes: 27 additions & 27 deletions Alexa-Hue Bridge.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def deviceStartCommAhb(self, ahbDev):
if ahbDev.address is None or ahbDev.address == '' or int(ahbDev.address) != int(port):
port_changed = True
except:
self.generalLogger.error("Alexa-Hue Bridge '{}' at address {} either has an invalid address or invalid port {} - specify in Device Config".format(ahbDev.name, ahbDev.address, port))
self.generalLogger.error(u"Alexa-Hue Bridge '{}' at address {} either has an invalid address or invalid port {} - specify in Device Config".format(ahbDev.name, ahbDev.address, port))
return

self.globals['alexaHueBridge'][ahbDev.id]['port'] = port
Expand Down Expand Up @@ -755,7 +755,7 @@ def retrievePublishedDevices(self, valuesDict, ahbDevId, infoMsg, convertVersion
elif numberPublished == 1:
numberPublishedUI = 'one Alexa Device'
else:
numberPublishedUI = str("{} Alexa Devices".format(numberPublished))
numberPublishedUI = str("u{} Alexa Devices".format(numberPublished))

if numberPublished <= DEVICE_LIMIT:
self.generalLogger.info(u"'{}' has {} published".format(self.globals['alexaHueBridge'][ahbDevId]['hubName'], numberPublishedUI))
Expand Down Expand Up @@ -915,7 +915,7 @@ def closedAhbDeviceConfigUi(self, valuesDict, userCancelled, typeId, ahbDevId):
elif numberPublished == 1:
numberPublishedUI = 'one Alexa Device'
else:
numberPublishedUI = str("{} Alexa Devices".format(numberPublished))
numberPublishedUI = str("u{} Alexa Devices".format(numberPublished))

if numberPublished <= DEVICE_LIMIT:
self.generalLogger.info(u"'{}' updated and now has {} published".format(self.globals['alexaHueBridge'][ahbDevId]['hubName'], numberPublishedUI))
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def disableAlexaVariableList(self, filter="", valuesDict=None, typeId="", target
variableName = indigo.variables[disableAlexaVariableId].name
else:
variableName = 'VARIABLE IS MISSING'
disableAlexa_dict.append((str(disableAlexaVariableId), "-- INVALID: {} --".format(variableName)))
disableAlexa_dict.append((str(disableAlexaVariableId), u"-- INVALID: {} --".format(variableName)))
for variable in indigo.variables.iter():
if variable.value.lower() == 'true' or variable.value.lower() == 'false':
variable_found = (str(variable.id), str(variable.name))
Expand All @@ -1048,7 +1048,7 @@ def alexaDevicesListGlobal(self, filter, valuesDict, typeId, ahbDevId):
alexaDeviceName = alexaDeviceData['name'].replace(',',' ').replace(';',' ')
self.globals['alexaDevicesListGlobal'][alexaDeviceNameKey] = int(alexaHueBridgeId)
alexaDeviceListKey = alexaDeviceNameKey + '|' + alexaDeviceName + '|' + str(alexaHueBridgeId)
alexaDeviceListKey = str('{}|{}|{}'.format(alexaDeviceNameKey, alexaDeviceName, alexaHueBridgeId))
alexaDeviceListKey = str(u'{}|{}|{}'.format(alexaDeviceNameKey, alexaDeviceName, alexaHueBridgeId))
allocatedAlexaDevicesListGlobal.append((alexaDeviceListKey, alexaDeviceName))

for alexaDeviceNameKey, alexaDeviceData in self.globals['alexaHueBridge'][ahbDevId]['publishedAlexaDevices'].iteritems():
Expand Down Expand Up @@ -1095,7 +1095,7 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if actionOnId in indigo.actionGroups:
valuesDict["alexaNameIndigoOnAction"] = indigo.actionGroups[actionOnId].name
else:
valuesDict["alexaNameIndigoOnAction"] = 'Action #{} not found'.format(actionOnId)
valuesDict[u"alexaNameIndigoOnAction"] = 'Action #{} not found'.format(actionOnId)

if actionOffId == 0:
valuesDict["alexaNameIndigoOffAction"] = 'NO ACTION'
Expand All @@ -1111,7 +1111,7 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if variableOnOffId in indigo.variables:
valuesDict["alexaNameIndigoOnOffActionVariable"] = indigo.variables[variableOnOffId].name
else:
valuesDict["alexaNameIndigoOnOffActionVariable"] = 'Variable #{} not found'.format(variableOnOffId)
valuesDict[u"alexaNameIndigoOnOffActionVariable"] = 'Variable #{} not found'.format(variableOnOffId)

if actionDimId == 0:
valuesDict["alexaNameIndigoDimAction"] = 'NO ACTION'
Expand All @@ -1121,15 +1121,15 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if actionDimId in indigo.actionGroups:
valuesDict["alexaNameIndigoDimAction"] = indigo.actionGroups[actionDimId].name
else:
valuesDict["alexaNameIndigoDimAction"] = 'Action #{} not found'.format(actionDimId)
valuesDict[u"alexaNameIndigoDimAction"] = 'Action #{} not found'.format(actionDimId)

if variableDimId == 0:
valuesDict["alexaNameIndigoDimActionVariable"] = 'NO VARIABLE'
else:
if variableDimId in indigo.variables:
valuesDict["alexaNameIndigoDimActionVariable"] = indigo.variables[variableDimId].name
else:
valuesDict["alexaNameIndigoDimActionVariable"] = 'Variable #{} not found'.format(variableDimId)
valuesDict[u"alexaNameIndigoDimActionVariable"] = 'Variable #{} not found'.format(variableDimId)

else:
valuesDict["alexaNameActionDevice"] = "D"
Expand All @@ -1138,7 +1138,7 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if deviceId in indigo.devices:
valuesDict["alexaNameIndigoDevice"] = deviceName
else:
valuesDict["alexaNameIndigoDevice"] = 'Device #{} not found (\'{}\' )'.format(deviceId, deviceName)
valuesDict[u"alexaNameIndigoDevice"] = 'Device #{} not found (\'{}\' )'.format(deviceId, deviceName)
valuesDict["alexaNameIndigoDeviceDimAction"] = self.globals['alexaHueBridge']['publishedOtherAlexaDevices'][alexaHueBridgeId][alexaDeviceNameKey].get('devDimAction', False)

else:
Expand All @@ -1159,23 +1159,23 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if actionOnId in indigo.actionGroups:
valuesDict["alexaNameIndigoOnAction"] = indigo.actionGroups[actionOnId].name
else:
valuesDict["alexaNameIndigoOnAction"] = 'Action #{} not found'.format(actionOnId)
valuesDict[u"alexaNameIndigoOnAction"] = 'Action #{} not found'.format(actionOnId)

if actionOffId == 0:
valuesDict["alexaNameIndigoOffAction"] = 'NO ACTION'
else:
if actionOffId in indigo.actionGroups:
valuesDict["alexaNameIndigoOffAction"] = indigo.actionGroups[actionOffId].name
else:
valuesDict["alexaNameIndigoOffAction"] = 'Action #{} not found'.format(actionOffId)
valuesDict[u"alexaNameIndigoOffAction"] = 'Action #{} not found'.format(actionOffId)

if variableOnOffId == 0:
valuesDict["alexaNameIndigoOnOffActionVariable"] = 'NO VARIABLE'
else:
if variableOnOffId in indigo.variables:
valuesDict["alexaNameIndigoOnOffActionVariable"] = indigo.variables[variableOnOffId].name
else:
valuesDict["alexaNameIndigoOnOffActionVariable"] = 'Variable #{} not found'.format(variableOnOffId)
valuesDict[u"alexaNameIndigoOnOffActionVariable"] = 'Variable #{} not found'.format(variableOnOffId)

if actionDimId == 0:
valuesDict["alexaNameIndigoDimAction"] = 'NO ACTION'
Expand All @@ -1185,23 +1185,23 @@ def alexaDevicesListGlobalSelection(self, valuesDict, typeId, ahbDevId):
if actionDimId in indigo.actionGroups:
valuesDict["alexaNameIndigoDimAction"] = indigo.actionGroups[actionDimId].name
else:
valuesDict["alexaNameIndigoDimAction"] = 'Action #{} not found'.format(actionDimId)
valuesDict[u"alexaNameIndigoDimAction"] = 'Action #{} not found'.format(actionDimId)

if variableDimId == 0:
valuesDict["alexaNameIndigoDimActionVariable"] = 'NO VARIABLE'
else:
if variableDimId in indigo.variables:
valuesDict["alexaNameIndigoDimActionVariable"] = indigo.variables[variableDimId].name
else:
valuesDict["alexaNameIndigoDimActionVariable"] = 'Variable #{} not found'.format(variableDimId)
valuesDict[u"alexaNameIndigoDimActionVariable"] = 'Variable #{} not found'.format(variableDimId)
else:
valuesDict["alexaNameActionDevice"] = "D"
deviceName = self.globals['alexaHueBridge'][alexaHueBridgeId]['publishedAlexaDevices'][alexaDeviceNameKey]['devName'].replace(',',' ').replace(';',' ')
deviceId = self.globals['alexaHueBridge'][alexaHueBridgeId]['publishedAlexaDevices'][alexaDeviceNameKey]['devId']
if deviceId in indigo.devices:
valuesDict["alexaNameIndigoDevice"] = deviceName
else:
valuesDict["alexaNameIndigoDevice"] = 'Device #{} not found (\'{}\' )'.format(deviceId, deviceName)
valuesDict[u"alexaNameIndigoDevice"] = 'Device #{} not found (\'{}\' )'.format(deviceId, deviceName)
valuesDict["alexaNameIndigoDeviceDimAction"] = self.globals['alexaHueBridge'][alexaHueBridgeId]['publishedAlexaDevices'][alexaDeviceNameKey].get('devDimAction', False)

valuesDict["alexaNameHueBridge"] = indigo.devices[int(alexaHueBridgeId)].name
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def addNewAlexaDevice(self, valuesDict, typeId, ahbDevId):
self.methodTracer.threaddebug(u"CLASS: Plugin")

if len(self.globals['alexaHueBridge'][ahbDevId]['publishedAlexaDevices']) >= DEVICE_LIMIT:
errorText = "You can't publish any more Alexa Devices - you've reached the maximum of {} imposed by the plugin on behalf of Amazon Alexa.".format(DEVICE_LIMIT)
errorText = u"You can't publish any more Alexa Devices - you've reached the maximum of {} imposed by the plugin on behalf of Amazon Alexa.".format(DEVICE_LIMIT)
self.generalLogger.error(errorText)
errorsDict = indigo.Dict()
errorsDict["showAlertText"] = errorText
Expand Down Expand Up @@ -1350,28 +1350,28 @@ def addNewAlexaDevice(self, valuesDict, typeId, ahbDevId):
if ahbDevId == alexaHueBridgeId:
errorsDict = indigo.Dict()
errorsDict["newAlexaName"] = "Duplicate Alexa Name"
errorsDict["showAlertText"] = "Alexa Device Name '{}' is already allocated on this Alexa-Hue Bridge".format(newAlexaName)
errorsDict["showAlertText"] = u"Alexa Device Name '{}' is already allocated on this Alexa-Hue Bridge".format(newAlexaName)
else:
alexaHueBridgeName = indigo.devices[alexaHueBridgeId].name
errorsDict = indigo.Dict()
errorsDict["newAlexaName"] = "Duplicate Alexa Name"
errorsDict["showAlertText"] = "Alexa Device Name '{}' is already allocated on Alexa-Hue Bridge '{}'".format(newAlexaName, alexaHueBridgeName)
errorsDict["showAlertText"] = u"Alexa Device Name '{}' is already allocated on Alexa-Hue Bridge '{}'".format(newAlexaName, alexaHueBridgeName)
return valuesDict, errorsDict

if valuesDict["actionOrDevice"] == 'D':
devId = int(valuesDict["sourceDeviceMenu"])
if devId == 0:
errorsDict = indigo.Dict()
errorsDict["newAlexaName"] = "Indigo Device not selected"
errorsDict["showAlertText"] = "No Indigo device selected for Alexa Device Name '{}'".format(newAlexaName)
errorsDict["showAlertText"] = u"No Indigo device selected for Alexa Device Name '{}'".format(newAlexaName)
return valuesDict, errorsDict
else: # Assume 'A' = Action
actionOnId = int(valuesDict["sourceOnActionMenu"])
actionOffId = int(valuesDict["sourceOffActionMenu"])
if actionOnId == 0 or actionOffId == 0:
errorsDict = indigo.Dict()
errorsDict["newAlexaName"] = "Indigo Actions not selected for On or Off or both"
errorsDict["showAlertText"] = "Indigo Actions not selected for On or Off or both, for Alexa Device Name '{}'".format(newAlexaName)
errorsDict["showAlertText"] = u"Indigo Actions not selected for On or Off or both, for Alexa Device Name '{}'".format(newAlexaName)
return valuesDict, errorsDict


Expand Down Expand Up @@ -1469,15 +1469,15 @@ def updateAlexaDevice(self, valuesDict, typeId, ahbDevId):
if devId == 0:
errorsDict = indigo.Dict()
errorsDict["updatedAlexaDeviceName"] = "Indigo Device not selected"
errorsDict["showAlertText"] = "No Indigo device selected for Alexa Device Name '{}'".format(updatedAlexaDeviceName)
errorsDict["showAlertText"] = u"No Indigo device selected for Alexa Device Name '{}'".format(updatedAlexaDeviceName)
return valuesDict, errorsDict
else: # Assume 'A' = Action
actionOnId = int(valuesDict["sourceOnActionMenu"])
actionOffId = int(valuesDict["sourceOffActionMenu"])
if actionOnId == 0 or actionOffId == 0:
errorsDict = indigo.Dict()
errorsDict["updatedAlexaDeviceName"] = "Indigo Actions not selected for On or Off or both"
errorsDict["showAlertText"] = "Indigo Actions not selected for On or Off or both, for Alexa Device Name '{}'".format(updatedAlexaDeviceName)
errorsDict["showAlertText"] = u"Indigo Actions not selected for On or Off or both, for Alexa Device Name '{}'".format(updatedAlexaDeviceName)
return valuesDict, errorsDict

alexaDeviceNameKey, alexaDeviceName, alexaHueBridgeId = valuesDict["alexaDevicesList"].split("|")
Expand All @@ -1488,12 +1488,12 @@ def updateAlexaDevice(self, valuesDict, typeId, ahbDevId):
if ahbDevId == alexaHueBridgeId:
errorsDict = indigo.Dict()
errorsDict["updatedAlexaDeviceName"] = "Duplicate Alexa Name"
errorsDict["showAlertText"] = "Alexa Device Name '{}' is already allocated on this Alexa-Hue Bridge".format(updatedAlexaDeviceName)
errorsDict["showAlertText"] = u"Alexa Device Name '{}' is already allocated on this Alexa-Hue Bridge".format(updatedAlexaDeviceName)
else:
alexaHueBridgeName = indigo.devices[alexaHueBridgeId].name
errorsDict = indigo.Dict()
errorsDict["updatedAlexaDeviceName"] = "Duplicate Alexa Name"
errorsDict["showAlertText"] = "Alexa Device Name '{}' is already allocated on Alexa-Hue Bridge '{}'".format(updatedAlexaDeviceName, alexaHueBridgeName)
errorsDict["showAlertText"] = u"Alexa Device Name '{}' is already allocated on Alexa-Hue Bridge '{}'".format(updatedAlexaDeviceName, alexaHueBridgeName)
return valuesDict, errorsDict


Expand Down Expand Up @@ -1597,12 +1597,12 @@ def publishedAlexaDevicesList(self, filter, valuesDict, typeId, ahbDevId):
if alexaData['devId'] in indigo.devices:
dev = indigo.devices[alexaData['devId']]
if dev.name != alexaDeviceName:
listName += " = {}".format(dev.name)
listName += u" = {}".format(dev.name)
else:
listName += " = MISSING!"
else: # Assume 'A' = Action
listName += " = ACTIONS"
alexaDeviceListKey = "{}|{}".format(alexaDeviceNameKey, alexaDeviceName)
alexaDeviceListKey = u"{}|{}".format(alexaDeviceNameKey, alexaDeviceName)
returnList.append((alexaDeviceListKey, listName))
returnList = sorted(returnList, key= lambda item: item[0])
return returnList
Expand Down

0 comments on commit 724ca23

Please sign in to comment.