text: import time
  
  class debounce_handler(object):
      """Use this handler to keep multiple Amazon Echo devices from reacting to
         the same voice command.
      """
      DEBOUNCE_SECONDS = 0.3
  
      def __init__(self):
          self.lastEcho = time.time()
  
      def on(self, client_address):
          if self.debounce():
              return True
          return self.act(client_address, True)
  
      def off(self, client_address):
          if self.debounce():
              return True
          return self.act(client_address, False)
  
      def act(self, client_address, state):
          pass
  
      def debounce(self):
          """If multiple Echos are present, the one most likely to respond first
             is the one that can best hear the speaker... which is the closest one.
             Adding a refractory period to handlers keeps us from worrying about
             one Echo overhearing a command meant for another one.
          """
          if (time.time() - self.lastEcho) < self.DEBOUNCE_SECONDS:
              return True
  
          self.lastEcho = time.time()
          return False
  
  
  