예제 #1
0
	def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs):
		indigo.PluginBase.__init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs)
		
		# EPS common startup
		try:
			self.debug = pluginPrefs["debugMode"]
			pollingMode = pluginPrefs["pollingMode"]
			pollingInterval = int(pluginPrefs["pollingInterval"])
			pollingFrequency = pluginPrefs["pollingFrequency"]
			self.monitor = pluginPrefs["monitorChanges"]
		except:
			indigo.server.log ("Preference options may have changed or are corrupt,\n\tgo to Plugins -> %s -> Configure to reconfigure %s and then reload the plugin.\n\tUsing defaults for now, the plugin should operate normally." % (pluginDisplayName, pluginDisplayName), isError = True)
			self.debug = False
			pollingMode = "realTime"
			pollingInterval = 1
			pollingFrequency = "s"
			self.monitor = False
			
		# EPS common variables and classes
		self.pluginUrl = ""
		eps.parent = self
		self.reload = False
		self.cache = cache (self, pluginId, pollingMode, pollingInterval, pollingFrequency)
		
		# EPS plugin specific variables and classes
		self.varCache = []
		epsdecon.parent = self
예제 #2
0
	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