Example #1
0
	def process(self):
		self.logger.debug("Processing TimeShiftActionRule...")
		isRuleEnabled = True
		try:
			isRuleEnabled = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getIsRuleEnabled()))
		except ValueError, e:
			self.logger.error("Error on TimeShiftActionRule.process(): %s. Setting True as default value for isRuleEnabled" % (e))
	def run (self):
		self.logger.info("DelayTimerActionRule.run(): switching off the applicances")
		isRuleEnabled = True
		try:
			isRuleEnabled = Utilities.to_bool (self.context.getProperty(ConfigurationConstants.getIsRuleEnabled()))
		except ValueError, e:
			self.logger.error("Error on DelayTimerActionRule.run(): %s. Setting True as defalut value for isRuleEnabled" % (e))
	def setPresenceValue(self, value):
		boolValue = False
		try:
			boolValue = Utilities.to_bool(value)
		except:
			self.logger.error("Error on DelayTimerActionRule.setPresenceValue(). Setting defalut Presence = %s mills. %s" %(boolValue, e))

		self.context.updateProperty(ConfigurationConstants.getPresence(), str(boolValue))
	def process(self):
		motion = False
		presence = False
		isRuleEnabled = True
		isMotionConsidered = False
		try:
			isRuleEnabled = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getIsRuleEnabled()))
		except ValueError, e:
					self.logger.error("Error on DelayTimerActionRule.process(): %s. Setting True as default value for isRuleEnabled" % (e))
Example #5
0
class TimeShiftActionRule(AbstractActionRule):

	def __init__(self, context, logger, mqttServiceProvider):
		super(TimeShiftActionRule, self).__init__(context, logger, mqttServiceProvider)
		self.isOffState = False
		self.isOnState = False


	def process(self):
		self.logger.debug("Processing TimeShiftActionRule...")
		isRuleEnabled = True
		try:
			isRuleEnabled = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getIsRuleEnabled()))
		except ValueError, e:
			self.logger.error("Error on TimeShiftActionRule.process(): %s. Setting True as default value for isRuleEnabled" % (e))
		
		try:
			self.isOffState = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getWeekdayOffState()))
			self.isOnState = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getWeekdayOnState()))
		except ValueError, e:
			self.logger.error("Error on TimeShiftActionRule.process(): %s. Setting False as default value for isOffState and isOnState" % (e))
			self.isOffState = False
			self.isOnState = False
Example #6
0
class LookOnPresenceRule(AbstractActionRule):
    def __init__(self, context, logger, mqttServiceProvider):
        super(LookOnPresenceRule, self).__init__(context, logger,
                                                 mqttServiceProvider)

    def process(self):
        self.logger.debug("Processing LookOnPresenceRule...")
        isRuleEnabled = True
        presence = False

        try:
            isRuleEnabled = Utilities.to_bool(
                self.context.getProperty(
                    ConfigurationConstants.getIsRuleEnabled()))
        except ValueError, e:
            self.logger.error(
                "Error on LookOnPresenceRule.process(): %s. Setting True as default value for isRuleEnabled"
                % (e))

        if isRuleEnabled:

            fullUserList = self.context.getProperty(
                ConfigurationConstants.getFullUserList())
            if fullUserList:
                users = ''.join(fullUserList.split()).split(';')
                for user in users:
                    if user:
                        try:
                            presence |= Utilities.to_bool(
                                self.context.getProperty(user))
                        except Exception, e:
                            self.logger.error(
                                "Error on LookOnPresenceRule.process(): Malformed boolean exception for user = %s. %s."
                                % (user, e))

#			try:
#				alldevices = Utilities.to_bool(self.context.getProperty("alldevices"))
#				if (alldevices == True):
#					presence = alldevices
#			except Exception, e:
#				self.logger.error("Error on LookOnPresenceRule.process(): Malformed boolean exception for alldevices = %s. %s." % (alldevices, e))

            if (presence):
                self.publishUnlook()
            else:
                self.publishLook()
Example #7
0
class VideoSurveillanceRule(AbstractActionRule):

	def __init__(self, context, logger, mqttServiceProvider):
		super(VideoSurveillanceRule, self).__init__(context, logger, mqttServiceProvider)


	def process(self):
		self.logger.debug("Processing VideoSurveillanceRule...")
		isRuleEnabled = True
		try:
			isRuleEnabled = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getIsRuleEnabled()))
		except ValueError, e:
			self.logger.error("Error on VideoSurveillanceRule.process(): %s. Setting True as default value for isRuleEnabled" % (e))
		
		try:
			self.isLooked = Utilities.to_bool(self.context.getProperty(ConfigurationConstants.getIsLooked()))
		except ValueError, e:
			self.logger.error("Error on VideoSurveillanceRule.process(): %s. Setting False as default value for isLooked " % (e))
			self.isLooked = False
		if not isRuleEnabled:
			#disable the timers
			self.cancelTimer()
			self.isDelayTimerOn = False
			
		else:
			self.defaultTimerInMills = self.toMinutes(self.context.getProperty(ConfigurationConstants.getAbsenceTimer()), True)

			fullSensorList = self.context.getProperty(ConfigurationConstants.getFullSensorList())
			if fullSensorList:
				sensors =  ''.join(fullSensorList.split()).split(';')
				for sensor in sensors:
					if sensor:
						try:
							motion |= Utilities.to_bool(self.context.getProperty(sensor))
							isMotionConsidered = True
						except Exception, e:
							self.logger.error("Error on DelayTimerActionRule.process(): Malformed boolean exception for sensorId = %s. %s." % (sensor, e))
			else:
				isMotionConsidered = False

			
			fullUserList = self.context.getProperty(ConfigurationConstants.getFullUserList())
			if fullUserList:
				users = ''.join(fullUserList.split()).split(';')
				for user in users:
					if user:
						try:
							presence |= Utilities.to_bool(self.context.getProperty(user))
						except Exception, e: