def do(self, action):
     print self._blinking_loop
     if self._blinking_loop is not None:
         try:
             self._blinking_loop.stop()
         except:
             pass
     if action is not None:
         for k, v in action.iteritems():
             if k == 'state':
                 grovepi.digitalWrite(self._pin, v)
             elif k == 'blink':
                 self._blinking_period = float(v)
                 self._blinking_loop = task.LoopingCall(self._blink)
                 self._blinking_loop.start(self._blinking_period)
     print 'action done'
 def do(self, action):
     if action is not None:
         for k, v in action.iteritems():
             if k == 'state':
                 grovepi.digitalWrite(self._pin, v)
 def _blink(self):
     grovepi.digitalWrite(self._pin, self._led_status)
     if self._led_status == 0:
         self._led_status = 1
     else:
         self._led_status = 0