Ejemplo n.º 1
0
def playnap(offset = 0, mediapath = "/home/pi/"):
	#blink all the indicators
    red.blink(0.25,0.25,5,1)
    red.off()
    i = 0
    while i <= 5:
      piglow.red(1)
      piglow.show()
      i += 1
      piglow.red(0)
      piglow.show()
      sleep(1)
Ejemplo n.º 2
0
	def printFile(self, filename):
		if self.piGlowEnable:
			piglow.all(0)
		if filename is not False:
			if self.piGlowEnable:
				piglow.green(255)
			print "PRINT: "+ str(filename) + " [Sent to printer]"
			self.conn.printFile(self.printer, filename, "Test", {"CutMedia": "2"})
		else:
			if self.piGlowEnable:
				piglow.red(255);
		if self.piGlowEnable:
			time.sleep(2)
			piglow.all(0)
			piglow.show()
Ejemplo n.º 3
0
    def turn_on(self, **kwargs):
        """Instruct the light to turn on."""
        piglow.clear()

        if ATTR_BRIGHTNESS in kwargs:
            self._brightness = kwargs[ATTR_BRIGHTNESS]

        if ATTR_HS_COLOR in kwargs:
            self._hs_color = kwargs[ATTR_HS_COLOR]

        rgb = color_util.color_hsv_to_RGB(self._hs_color[0], self._hs_color[1],
                                          self._brightness / 255 * 100)
        piglow.red(rgb[0])
        piglow.green(rgb[1])
        piglow.blue(rgb[2])
        piglow.show()
        self._is_on = True
        self.schedule_update_ha_state()
Ejemplo n.º 4
0
	def shutdown(self):
		try:
			print '\nShutting down HomePi!!'
			self.notifyShutdown()
			#self.bRunning = False
			
			# Feedback - Performing cleanup
			piglow.blue(0)
			piglow.red(self.feedbackGlow)
			piglow.show()

			# Start device disconnect.
			self.disconnectFromDevices(self.connectedDevices)
			self.disconnectFromClients(self.connectedClients)		
			self.notifyShutdown()
			self.btServerSocket.close()
			print '\nServer Socket Closed'
		except bluetooth.btcommon.BluetoothError:
			pass
Ejemplo n.º 5
0
    def shutdown(self):
        try:
            print '\nShutting down HomePi!!'
            self.notifyShutdown()
            #self.bRunning = False

            # Feedback - Performing cleanup
            piglow.blue(0)
            piglow.red(self.feedbackGlow)
            piglow.show()

            # Start device disconnect.
            self.disconnectFromDevices(self.connectedDevices)
            self.disconnectFromClients(self.connectedClients)
            self.notifyShutdown()
            self.btServerSocket.close()
            print '\nServer Socket Closed'
            time.sleep(3)

        except bluetooth.btcommon.BluetoothError:
            pass
Ejemplo n.º 6
0
def update_pressure():
    """ Broadcast the current accumulator pressure """
    pressure = pressure_sensor.read_pressure()
    poof_track.add_observation(pressure)
    if metrics.pressure.empty or poof_track.poofing():
        piglow.red(64)
        piglow.show()
        broadcast("/pressure", float(pressure))
        metrics.pressure = pd.concat([
            metrics.pressure,
            pd.DataFrame.from_records([{
                "timestamp": metrics.now_string(),
                "level": pressure
            }]),
        ])
        broadcast("/poof_count", float(poof_track.poof_count))
        logger.info(f"Pressure = {pressure}")
    elif not poof_track.poofing():
        piglow.red(0)
        piglow.show()
        poof_track.stop()
        broadcast("/poof_seconds", float(poof_track.poof_time))
Ejemplo n.º 7
0
    def init(self, configFile):

        # Track the file used to configure the current instance
        self.configFilePath = configFile

        # Set up handler for process termination
        signal.signal(signal.SIGTERM, onHomePiKilled)
        signal.signal(signal.SIGINT, onHomePiKilled)

        # Create a lock object for synchronization.
        self.threadLock = threading.Lock()

        # Feedback -  Performing cleanup.
        piglow.red(self.feedbackGlow)
        piglow.show()

        print 'Closing all existing GATT Connections... '
        self.closeAllGattConnections()
        print 'Done'

        # Feedback - Performing Config Initialization.
        piglow.red(0)
        piglow.orange(self.feedbackGlow)
        piglow.show()

        print 'Loading Home Devices... '
        regDevices = self.loadDevicesJSON(configFile)
        print 'Done Loading Home Device!'

        # Feedback - Connecting to registered devices.
        piglow.orange(0)
        piglow.yellow(self.feedbackGlow)
        piglow.show()

        print '\nAttempting connection to devices...'
        self.connectToRegisteredDevices(regDevices)
        print '\nConnection attempt done!'

        # Note: Seemed like a good idea but slows
        # down interaction with the HomePi while it is
        # trying to connect to the unavailable devices.
        # Removing for now until a better solution comes
        # to mind.
        #print '\nSpawning Device Checker Thread...'
        #self.statusChecker = HomePiDeviceStatusCheckerThread(self, 15)
        #self.statusChecker.setDaemon(True)
        #self.statusChecker.start()

        # Feedback - Ready and waiting for connections.
        piglow.red(0)
        piglow.orange(0)
        piglow.yellow(0)

        piglow.blue(self.feedbackGlow)
        piglow.show()

        # Listening to devices...
        self.listenForClients()
Ejemplo n.º 8
0
	def init(self, configFile):
	 
		# Set up handler for process termination
		signal.signal(signal.SIGTERM, onHomePiKilled)
		signal.signal(signal.SIGINT, onHomePiKilled)
	
		# Create a lock object for synchronization.
		self.threadLock = threading.Lock()

		# Feedback -  Performing cleanup.
		piglow.red(self.feedbackGlow)
		piglow.show()

		print 'Closing all existing GATT Connections... '
		self.closeAllGattConnections()	
		print 'Done'
		
		# Feedback - Performing Config Initialization.
		piglow.red(0)
		piglow.orange(self.feedbackGlow)
		piglow.show()

		print 'Loading Home Devices... '
		regDevices = self.loadDevicesJSON(configFile)
		print 'Done Loading Home Device!'

		# Feedback - Connecting to registered devices.
		piglow.orange(0)
		piglow.yellow(self.feedbackGlow)
		piglow.show()

		print '\nAttempting connection to devices...'
		self.connectToRegisteredDevices(regDevices)
		print '\nConnection attempt done!'
		
		# Note: Seemed like a good idea but slows 
		# down interaction with the HomePi while it is 
		# trying to connect to the unavailable devices.
		# Removing for now until a better solution comes
		# to mind.
		#print '\nSpawning Device Checker Thread...'
		#self.statusChecker = HomePiDeviceStatusCheckerThread(self, 15)
		#self.statusChecker.setDaemon(True)
		#self.statusChecker.start()
		
		# Feedback - Ready and waiting for connections.
		piglow.red(0)
		piglow.orange(0)
		piglow.yellow(0)

		piglow.blue(self.feedbackGlow)
		piglow.show()

		# Listening to devices...	
		self.listenForClients()
Ejemplo n.º 9
0
def glow(color="green"):
  if showLight:
      print("Make the World bright")
      try:
        if color=="green":
          piglow.green(200)
          piglow.red(0)
          piglow.orange(0)
        elif color=="red":
          piglow.green(0)
          piglow.red(150)
          piglow.orange(0)
        else:
          piglow.green(0)
          piglow.red(0)
          piglow.orange(150)
        piglow.show()
      except Exception as ex:
        print(ex)
Ejemplo n.º 10
0
def redLine():
    logging.debug('Red Line')
    piglow.red(255)
Ejemplo n.º 11
0
red.off()
piglow.all(0)
piglow.show()
#function to gradually change the volume
def rampvol(speed = 0.25, start = 0, stop = 100, step = 1):
	vol = start
	while vol != stop:
		vol = vol + step
		system("amixer -q sset PCM,0 " + str(vol) + "%")
		sleep(speed)
#blink all the indicators
red.blink(0.25,0.25,5,1)
red.off()
i = 0
while i <= 5:
	piglow.red(1)
	piglow.show()
	i += 1
	sleep(0.5)
	piglow.red(0)
	piglow.show()
	sleep(0.5)
day = int(time.strftime("%j")) #get the day of the year [0,366]
playlist = ( int(day) + offset ) % 2
if playlist == 0:
	if day > 330: #kiss me baby, it's christmas time
		maxvol = 80
		system("mpg321 --random " + mediapath + "christmas/* &")
	else:
		maxvol = 90
		system("mpg321 --random " + mediapath + "music/* &")
Ejemplo n.º 12
0
	def __init__(self):
		self.configFileLocation = os.getenv('CONFFILE', self.configFileLocation)
		self.config = ConfigParser.ConfigParser()
		#Try to load config file
		
		if self.configFileLocation not in self.config.read(self.configFileLocation):
			self.configFileLocation = None
			
		#Try to set rfid input path from config file.
		try:
			self.rfidPath = self.config.get('Parkomatic', 'rfid_input_path')
		except: 
			pass
		
		#Try to set destination URL from config file.
		try:
			self.URL = self.config.get('Parkomatic', 'url')
		except:
			pass
		
		#Try to set tmp path from config file.
		try:
			self.tmpLocation = self.config.get('Parkomatic', 'tmp_path')
		except:
			pass
		
		try:
			piglow_val = self.config.get('Parkomatic', 'piglow')
			if piglow_val == "enable":
				self.piGlowEnable = True
		except:
			 pass
		
		#Try to create the tmp location if it doesn't exist
		if not os.path.exists(self.tmpLocation):
			os.makedirs(self.tmpLocation)
		
		#Make a connection to the CUPS server
		try:
			self.conn = cups.Connection()
		except:
			print "ERROR: CUPs not available"
			#Sleep for 5 seconds as repeatedly attemping to connect to CUPs seems to make it hard for cups to start initially.
			time.sleep(5)
			sys.exit(1)
			
		printers = self.conn.getPrinters()
		if len(printers) == 0:
			print "ERROR: No printers available"
			time.sleep(5)
			sys.exit(1)
		#Get the first printer in the list
		self.printer = printers.keys()[0]
		
		#Create the RFID input device
		self.rfidDevice = InputDevice(self.rfidPath)
		print "STARTED: Waiting for input."
		if self.piGlowEnable:
			piglow.auto_update = True;
			piglow.all(0)
			piglow.red(255)
			time.sleep(0.1)
			piglow.red(0)
			piglow.green(255)
			time.sleep(0.1)
			piglow.green(0)
			piglow.yellow(255)
			time.sleep(0.1)
			piglow.white(255)
			piglow.yellow(0)
			time.sleep(0.1)
			piglow.white(0)
Ejemplo n.º 13
0
        piglow.show()
        time.sleep(0.01)
     for x in reversed(range(100)):
        piglow.leg_bar(0, x / 100.0)
        #piglow.leg_bar(1, x / 100.0)
        #piglow.leg_bar(2, x / 100.0)
        piglow.white(200)
        piglow.show()
        time.sleep(0.01) 
          
  elif hourlyData.icon == "sleet":
  for x in range(100):
        piglow.leg_bar(0, x / 100.0)
        #piglow.leg_bar(1, x / 100.0)
        #piglow.leg_bar(2, x / 100.0)
        piglow.red(200)
        piglow.show()
        time.sleep(0.01)
     for x in reversed(range(100)):
        piglow.leg_bar(0, x / 100.0)
        #piglow.leg_bar(1, x / 100.0)
        #piglow.leg_bar(2, x / 100.0)
        piglow.red(200)
        piglow.show()
        time.sleep(0.01) 
 
  
  elif hourlyData.icon == "fog":
 for x in range(100):
        piglow.leg_bar(0, x / 100.0)
        #piglow.leg_bar(1, x / 100.0)
Ejemplo n.º 14
0
    def __init__(self):
        self.configFileLocation = os.getenv('CONFFILE',
                                            self.configFileLocation)
        self.config = ConfigParser.ConfigParser()
        #Try to load config file

        if self.configFileLocation not in self.config.read(
                self.configFileLocation):
            self.configFileLocation = None

        #Try to set rfid input path from config file.
        try:
            self.rfidPath = self.config.get('Parkomatic', 'rfid_input_path')
        except:
            pass

        #Try to set destination URL from config file.
        try:
            self.URL = self.config.get('Parkomatic', 'url')
        except:
            pass

        #Try to set tmp path from config file.
        try:
            self.tmpLocation = self.config.get('Parkomatic', 'tmp_path')
        except:
            pass

        try:
            piglow_val = self.config.get('Parkomatic', 'piglow')
            if piglow_val == "enable":
                self.piGlowEnable = True
        except:
            pass

        #Try to create the tmp location if it doesn't exist
        if not os.path.exists(self.tmpLocation):
            os.makedirs(self.tmpLocation)

        #Make a connection to the CUPS server
        try:
            self.conn = cups.Connection()
        except:
            print "ERROR: CUPs not available"
            #Sleep for 5 seconds as repeatedly attemping to connect to CUPs seems to make it hard for cups to start initially.
            time.sleep(5)
            sys.exit(1)

        printers = self.conn.getPrinters()
        if len(printers) == 0:
            print "ERROR: No printers available"
            time.sleep(5)
            sys.exit(1)
        #Get the first printer in the list
        self.printer = printers.keys()[0]

        #Create the RFID input device
        self.rfidDevice = InputDevice(self.rfidPath)
        print "STARTED: Waiting for input."
        if self.piGlowEnable:
            piglow.auto_update = True
            piglow.all(0)
            piglow.red(255)
            time.sleep(0.1)
            piglow.red(0)
            piglow.green(255)
            time.sleep(0.1)
            piglow.green(0)
            piglow.yellow(255)
            time.sleep(0.1)
            piglow.white(255)
            piglow.yellow(0)
            time.sleep(0.1)
            piglow.white(0)
Ejemplo n.º 15
0
        percent = float(pihole.ads_percentage)  # Example: 31.2
        x = 0.0
        while x < percent:
            if x < percent - 10:
                x += 10.0
                flash_blue()  # 10%
            elif x < percent - 5:
                x += 5.0
                flash_orange()  # 5%
            else:
                x += 1.0
                flash_yellow()  # 1%

    refresh = get_ads()  # Get the current number of ads blocked

    if refresh > ads:
        flash_yellow()
        flash_orange()
        while refresh > ads:  # The refreshed number of ads is larger than tracked
            flash_red()  # Function Call, flash_red LED
            ads += 1  # Increment tracked ads

    # Idle for a number of seconds to reduce refresh rate
    time.sleep(SYS_WAIT)
    system_cycles += 1
    enabled = check_status()

#When disabled show solid red
piglow.red(RED)
piglow.show()