diff --git a/Pushover.indigoPlugin/Contents/Info.plist b/Pushover.indigoPlugin/Contents/Info.plist index 13a221c..bd4beb4 100644 --- a/Pushover.indigoPlugin/Contents/Info.plist +++ b/Pushover.indigoPlugin/Contents/Info.plist @@ -3,7 +3,7 @@ PluginVersion - 2022.0.0 + 2022.0.1 ServerApiVersion 3.0 IwsApiVersion diff --git a/Pushover.indigoPlugin/Contents/Server Plugin/PluginConfig.xml b/Pushover.indigoPlugin/Contents/Server Plugin/PluginConfig.xml index 040adc2..407d8c3 100644 --- a/Pushover.indigoPlugin/Contents/Server Plugin/PluginConfig.xml +++ b/Pushover.indigoPlugin/Contents/Server Plugin/PluginConfig.xml @@ -4,7 +4,7 @@ - + diff --git a/Pushover.indigoPlugin/Contents/Server Plugin/plugin.py b/Pushover.indigoPlugin/Contents/Server Plugin/plugin.py index 682cc01..8cc747a 100644 --- a/Pushover.indigoPlugin/Contents/Server Plugin/plugin.py +++ b/Pushover.indigoPlugin/Contents/Server Plugin/plugin.py @@ -15,20 +15,20 @@ def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs): self.logLevel = int(pluginPrefs.get("logLevel", logging.INFO)) self.indigo_log_handler.setLevel(self.logLevel) self.logger.debug(f"logLevel = {self.logLevel}") - + self.apiToken = None self.sounds = None + def startup(self): + self.logger.debug(f"startup called") self.apiToken = pluginPrefs.get('apiToken', None) if not self.apiToken: self.logger.warning(f"PI Token not configured") - def startup(self): - self.logger.debug(f"startup called") try: r = requests.get(f"https://api.pushover.net/1/sounds.json?token={self.apiToken}") - customdecoder = json.JSONDecoder(object_hook=OrderedDict) - rdict = customdecoder.decode(r.text) + custom_decoder = json.JSONDecoder(object_hook=OrderedDict) + rdict = custom_decoder.decode(r.text) self.sounds = rdict['sounds'] except Exception as err: self.logger.warning(f"Error getting alert sounds list: {err}") @@ -156,12 +156,28 @@ def cancel(self, pluginAction): # ConfigUI methods ######################################## + def validatePrefsConfigUi(self, valuesDict): + self.logger.debug(u"validatePrefsConfigUi called") + errorMsgDict = indigo.Dict() + + if valuesDict["apiToken"] == "": + errorMsgDict['apiToken'] = "API Token is required" + + if len(errorMsgDict) > 0: + return False, valuesDict, errorMsgDict + return True, valuesDict + def closedPrefsConfigUi(self, valuesDict, userCancelled): + self.logger.debug(u"closedPrefsConfigUi called") if not userCancelled: self.logLevel = int(valuesDict.get("logLevel", logging.INFO)) self.indigo_log_handler.setLevel(self.logLevel) self.logger.debug(f"logLevel = {self.logLevel}") + self.apiToken = valuesDict.get('apiToken', None) + if not self.apiToken: + self.logger.error(f"API Token not configured") + # doesn't do anything, just needed to force other menus to dynamically refresh @staticmethod def menuChanged(valuesDict, typeId, devId):