예제 #1
0
	def setState(self, state):
		if self.type == 'GPIO':
			new_state = 1 - self.active - state
			GPIO.output(self.pin, new_state)
			if GPIO.input(self.pin) is self.active:
				return 1
			else:
				return 0
예제 #2
0
파일: appliance.py 프로젝트: zan73/WebGPIO
 def executeAction(self):
     if self.type == 'GPIO':
         original_state = GPIO.input(self.pin)
         new_state = 1 - original_state
         GPIO.output(self.pin, new_state)
         if 'Duration' in self.attributes:
             time.sleep(self.attributes['Duration'])
             GPIO.output(self.pin, original_state)
     if self.type == 'Script' and self.action:
         if self.getState():
             subprocess.call([self.off_cmd], shell=True)
         else:
             subprocess.call([self.on_cmd], shell=True)
예제 #3
0
파일: appliance.py 프로젝트: zan73/WebGPIO
 def getState(self):
     if self.type == 'GPIO':
         if GPIO.input(self.pin) is self.active:
             return 1
         else:
             return 0
     else:
         #get the state of other Appliances in other rooms
         #not properly implemented yet
         returnCode = subprocess.call([self.status_cmd], shell=True)
         if returnCode == 0:
             return 1
         return 0