Example #1
0
	def deviceUpdated(self, origDev, newDev):
		if self.cache is None: return
		
		if origDev.pluginId == self.pluginId:
			self.debugLog(u"Plugin device %s was updated" % origDev.name)
			
			if eps.isNewDevice(origDev, newDev):
				self.debugLog("New device '%s' detected, restarting device communication" % newDev.name)
				self.deviceStartComm (newDev)
				return							
						
			# Re-cache the device and it's subdevices and states
			if eps.propsChanged (origDev, newDev):
				# Assume that the properties now allow the alarm to be a different day, including today, so set the alarm to today and validate it
				startTime = datetime.datetime.strptime (newDev.states["startTime"], "%Y-%m-%d %H:%M:%S")
				d = indigo.server.getTime()
				newStartTime = datetime.datetime.strptime(d.strftime("%Y-%m-%d") + startTime.strftime(" %H:%M:%S"), "%Y-%m-%d %H:%M:%S")
				
				# Write the new start time to the device, when startComm runs again it will re-validate it so this should be fine
				newDev.updateStateOnServer("startTime", newStartTime.strftime ("%Y-%m-%d %H:%M:%S"))
			
				self.debugLog(u"Plugin device %s settings changed, rebuilding watched states" % origDev.name)
				self.cache.removeDevice (origDev.id)
				self.deviceStartComm (newDev)
				
		else:
			changedStates = self.cache.watchedStateChanged (origDev, newDev)
			if changedStates:
				self.debugLog(u"The monitored device %s had a watched state change" % origDev.name)
				# Send parent device array and changed states array to function to disseminate
				#indigo.server.log(unicode(changedStates))
				X = 1 # placeholder
			
		return
Example #2
0
	def deviceUpdated(self, origDev, newDev):
		if self.cache is None: return
		
		if newDev.pluginId == self.pluginId:
			#self.debugLog(u"Plugin device %s was updated" % origDev.name)
			
			# Re-cache the device and it's subdevices and states
			if eps.propsChanged (origDev, newDev):
				self.debugLog(u"Plugin device %s settings changed, rebuilding watched states" % origDev.name)
				self.cache.removeDevice (origDev.id)
				self.deviceStartComm (newDev)
						
		else:
			changedStates = self.cache.watchedStateChanged (origDev, newDev)
			if changedStates:
				self.debugLog(u"The monitored device %s had a watched state change" % origDev.name)
				#indigo.server.log(unicode(changedStates))
				plug.updateChangedLCD (newDev, changedStates)
				
			changedStates = self.cache.watchedPropertyChanged (origDev, newDev)
			if changedStates:
				self.debugLog(u"The monitored device %s had a watched property change" % origDev.name)
				
				for devId, devProps in changedStates.iteritems():
					dev = indigo.devices[devId]
					if dev.deviceTypeId == "epslcddt":
						self.dateTimeDeviceUpdate (dev, dev.lastChanged)
				
		return