예제 #1
0
def checkInternet():
    logging.debug('Check Internet')
    pingstatus = 1
    while pingstatus != 0:
        pingstatus = os.system("ping -c 1 -i 1 trimet.org")
        if pingstatus != 0:
            piglow.clear()
            piglow.show()
            errorStatus()
예제 #2
0
def flash_orange():

    # Turn off all, turn on orange
    piglow.clear()
    piglow.orange(ORANGE)
    piglow.show()
    # Leave on for 0.1 seconds
    time.sleep(0.1)

    # Leave off for 0.1 seconds
    piglow.clear()
    piglow.show()
    time.sleep(0.1)
예제 #3
0
def flash_yellow():

    # Turn off all, turn on yellow
    piglow.clear()
    piglow.yellow(YELLOW)
    piglow.show()
    # Leave on for 0.1 seconds
    time.sleep(0.1)

    # Leave off for 0.1 seconds
    piglow.clear()
    piglow.show()
    time.sleep(0.1)
예제 #4
0
def flash_green():

    # Turn off all, turn on green
    piglow.clear()
    piglow.green(GREEN)
    piglow.show()
    # Leave on for 0.1 seconds
    time.sleep(0.2)

    # Leave off for 0.1 seconds
    piglow.clear()
    piglow.show()
    time.sleep(0.2)
예제 #5
0
def flash_blue():

    # Turn off all, turn on blue
    piglow.clear()
    piglow.blue(BLUE)
    piglow.show()
    # Leave on for 0.1 seconds
    time.sleep(0.2)

    # Leave off for 0.1 seconds
    piglow.clear()
    piglow.show()
    time.sleep(0.2)
예제 #6
0
def flash_red():

    # Turn off all, turn on red
    piglow.clear()
    piglow.red(RED)
    piglow.show()

    # Leave on for 0.1 seconds
    time.sleep(0.1)

    # Leave off for 0.1 seconds
    piglow.clear()
    piglow.show()
    time.sleep(0.1)
예제 #7
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()
예제 #8
0
 def __init__(self,
              time_zone,
              piglow_enabled,
              channel_com=None,
              logger=None):
     self.logger = logger or logging.getLogger("ToddlerClock")
     self.colors = ['blue', 'yellow', 'green', 'orange', 'white', 'red']
     self.timing = {}
     self.state = {}
     for c in self.colors:
         self.state[c] = {
             'on': False,
             'brightness': 0,
             'override_intervals': False
         }
         self.timing[c] = []
     self.channel_com = channel_com
     self.tz = time_zone
     self.piglow_enabled = piglow_enabled
     if piglow_enabled:
         piglow.auto_update = True
         piglow.clear()
예제 #9
0
            trainTable = []
            for train in sched['resultSet']['arrival']:
                if train['status'] == 'estimated':
                    if (train['estimated'] / 1000) > tooearly and (
                            train['estimated'] / 1000) < toolate:
                        #trainColor[train['route']]()
                        routenum = train['route']
                        trainTable.append([routenum, 'est', 'on'])
                else:
                    if (train['scheduled'] / 1000) > tooearly and (
                            train['scheduled'] / 1000) < toolate:
                        routenum = train['route']
                        trainTable.append([routenum, 'sched', 'on'])

            piglow.clear()
            for color in trainTable:
                if color[1] == 'est':
                    trainColor[color[0]]()
                else:
                    if color[2] == 'on':
                        trainColor[color[0]]()
                        color[2] = 'off'
                    else:
                        color[2] = 'on'
            #print 'Next: {table} - new data in {nextcall} second(s).'.format(table = trainTable, nextcall = apiCounter)
            piglow.show()
        except:
            checkInternet()

    apiCounter -= 1
예제 #10
0
 def turn_off(self, **kwargs):
     """Instruct the light to turn off."""
     piglow.clear()
     piglow.show()
     self._is_on = False
     self.schedule_update_ha_state()