def pluginInit (self): try: # New global for initialized class versions that the plugin adds #self.CLASSVERSIONS = [] #self.CLASSVERSIONS.append("xyz: " + self.xyz.version) return except Exception as e: msg = eps.debugHeader ("Plugin intialization had an error, restart required!") self.logger.critical(msg) eps.printException(e) raise
def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs): indigo.PluginBase.__init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs) try: self.TVERSION = "2.0.1" self.epsInit() self.pluginInit() except Exception as e: msg = eps.debugHeader ("Plugin intialization had an error, restart required!") self.logger.critical(msg) eps.printException(e) raise
def showLibraryVersions (self, forceDebug = False): s = eps.debugHeader("LIBRARY VERSIONS") s += eps.debugLine (self.pluginDisplayName + " - v" + self.pluginVersion) s += eps.debugHeaderEx () s += eps.debugLine ("Cache %s" % self.cache.version) s += eps.debugLine ("UI %s" % ui.libVersion(True)) s += eps.debugLine ("DateTime %s" % dtutil.libVersion(True)) s += eps.debugLine ("Core %s" % eps.libVersion(True)) s += eps.debugHeaderEx () if forceDebug: self.debugLog (s) return indigo.server.log (s)
def showLibraryVersions (self, forceDebug = False): try: s = eps.debugHeader("LIBRARY VERSIONS") s += eps.debugLine (self.pluginDisplayName + " - v" + self.pluginVersion) s += eps.debugHeaderEx () if "TVERSION" in dir(self): s += eps.debugLine("base: " + self.TVERSION) s += eps.debugLine(" ") s += eps.debugLine("indigo: " + indigo.server.version) for name, val in globals().items(): if isinstance(val, types.ModuleType) or isinstance(val, types.ClassType): #self.logger.info(val.__name__) if "libversion" in dir(val): libname = val.__name__ libversion = getattr(val, "libversion") #() # Resolve common (and potentially confusing) lib names if libname == "eps.eps": libname = "core" if libname == "eps.dtutil": libname = "dtutil" if libname == "eps.ui": libname = "ui" s += eps.debugLine(libname + ": " + libversion) # Check for common libraries if "cache" in dir(self): s += eps.debugLine("cache: " + self.cache.version) if "cond" in dir(self): s += eps.debugLine("conditions: " + self.cond.version) if "eto" in dir(self): s += eps.debugLine("eto: " + self.eto.version) if "sprinkler" in dir(self): s += eps.debugLine("sprinkler: " + self.sprinkler.version) # Iterate over our loaded classes and add them if "CLASSVERSIONS" in dir(self): for v in self.CLASSVERSIONS: s += eps.debugLine(v) s += eps.debugHeaderEx () if forceDebug: self.logger.debug (s) return indigo.server.log (s) # leaving at legacy logging to ensure it gets output no matter what except Exception as e: eps.printException(e)
def epsInit (self): try: # Set any missing prefs self.pluginPrefs = eps.validateDictValue (self.pluginPrefs, "logLevel", "20", True) self.pluginPrefs = eps.validateDictValue (self.pluginPrefs, "pollingMode", "realTime", True) self.pluginPrefs = eps.validateDictValue (self.pluginPrefs, "pollingInterval", 1, True) self.pluginPrefs = eps.validateDictValue (self.pluginPrefs, "pollingFrequency", "s", True) # Change this to true if we are watching devices self.pluginPrefs = eps.validateDictValue (self.pluginPrefs, "monitorChanges", False, True) # EPS common startup self.logger.setLevel(int(self.pluginPrefs["logLevel"])) if int(self.pluginPrefs["logLevel"]) < 20: self.debug = True else: self.debug = False pollingMode = self.pluginPrefs["pollingMode"] pollingInterval = int(self.pluginPrefs["pollingInterval"]) pollingFrequency = self.pluginPrefs["pollingFrequency"] self.monitor = self.pluginPrefs["monitorChanges"] # Legacy cleanup (Indigo 7 removes need for debug mode and may eliminate it entirely at some point) if eps.valueValid (self.pluginPrefs, "debugMode"): self.logger.info(u"Upgraded plugin preferences from pre-Indigo 7, depreciated preferences removed") del self.pluginPrefs["debugMode"] # EPS common variables and classes self.pluginUrl = "http://forums.indigodomo.com/viewtopic.php?f=196&t=16343" eps.parent = self self.reload = False self.cache = cache (self, self.pluginId, pollingMode, pollingInterval, pollingFrequency) self.cond = conditions (self) except Exception as e: msg = eps.debugHeader ("Plugin intialization had an error, restart required!") self.logger.critical(msg) eps.printException(e) raise
def supportLog (self): self.showLibraryVersions () s = eps.debugHeader("SUPPORT LOG") # Get plugin prefs s += eps.debugHeader ("PLUGIN PREFRENCES", "=") for k, v in self.pluginPrefs.iteritems(): s += eps.debugLine(k + " = " + unicode(v), "=") s += eps.debugHeaderEx ("=") # Report on cache s += eps.debugHeader ("DEVICE CACHE", "=") for devId, devProps in self.cache.devices.iteritems(): s += eps.debugHeaderEx ("*") s += eps.debugLine(devProps["name"] + ": " + str(devId) + " - " + devProps["deviceTypeId"], "*") s += eps.debugHeaderEx ("*") s += eps.debugHeaderEx ("-") s += eps.debugLine("SUBDEVICES", "-") s += eps.debugHeaderEx ("-") for subDevId, subDevProps in devProps["subDevices"].iteritems(): s += eps.debugHeaderEx ("+") s += eps.debugLine(subDevProps["name"] + ": " + str(devId) + " - " + subDevProps["deviceTypeId"] + " (Var: " + subDevProps["varName"] + ")", "+") s += eps.debugHeaderEx ("+") s += eps.debugLine("WATCHING STATES:", "+") for z in subDevProps["watchStates"]: s += eps.debugLine(" " + z, "+") s += eps.debugHeaderEx ("+") s += eps.debugLine("WATCHING PROPERTIES:", "+") for z in subDevProps["watchProperties"]: s += eps.debugLine(" " + z, "+") if subDevId in indigo.devices: d = indigo.devices[subDevId] if d.pluginId != self.pluginId: s += eps.debugHeaderEx ("!") s += eps.debugLine(d.name + ": " + str(d.id) + " - " + d.deviceTypeId, "!") s += eps.debugHeaderEx ("!") s += eps.debugHeaderEx ("-") s += eps.debugLine("PREFERENCES", "-") s += eps.debugHeaderEx ("-") for k, v in d.pluginProps.iteritems(): s += eps.debugLine(k + " = " + unicode(v), "-") s += eps.debugHeaderEx ("-") s += eps.debugLine("STATES", "-") s += eps.debugHeaderEx ("-") for k, v in d.states.iteritems(): s += eps.debugLine(k + " = " + unicode(v), "-") s += eps.debugHeaderEx ("-") s += eps.debugLine("RAW DUMP", "-") s += eps.debugHeaderEx ("-") s += unicode(d) + "\n" s += eps.debugHeaderEx ("-") else: s += eps.debugHeaderEx ("!") s += eps.debugLine("Plugin Device Already Summarized", "+") s += eps.debugHeaderEx ("!") else: s += eps.debugHeaderEx ("!") s += eps.debugLine("!!!!!!!!!!!!!!! DEVICE DOES NOT EXIST IN INDIGO !!!!!!!!!!!!!!!", "+") s += eps.debugHeaderEx ("!") s += eps.debugHeaderEx ("-") s += eps.debugHeaderEx ("=") # Loop through all devices for this plugin and report s += eps.debugHeader ("PLUGIN DEVICES", "=") for dev in indigo.devices.iter(self.pluginId): s += eps.debugHeaderEx ("*") s += eps.debugLine(dev.name + ": " + str(dev.id) + " - " + dev.deviceTypeId, "*") s += eps.debugHeaderEx ("*") s += eps.debugHeaderEx ("-") s += eps.debugLine("PREFERENCES", "-") s += eps.debugHeaderEx ("-") for k, v in dev.pluginProps.iteritems(): s += eps.debugLine(k + " = " + unicode(v), "-") s += eps.debugHeaderEx ("-") s += eps.debugLine("STATES", "-") s += eps.debugHeaderEx ("-") for k, v in dev.states.iteritems(): s += eps.debugLine(k + " = " + unicode(v), "-") s += eps.debugHeaderEx ("-") s += eps.debugHeaderEx ("=") indigo.server.log(s)