Exemple #1
0
 def _process_device(self, device, cache=None):
     if isinstance(device, Switch):
         callback = self._switch_callback
         registry = self._switches
     elif isinstance(device, Motion):
         callback = self._motion_callback
         registry = self._motions
     else:
         return
     self.devices[device.name] = device
     registry[device.name] = device
     if self._with_subscribers:
         self.registry.register(device)
         self.registry.on(device, 'BinaryState',
                          device._update_state)
     with get_cache() as c:
         try:
             device.ping()
         except DeviceUnreachable:
             return
         else:
             if cache if cache is not None else self._with_cache:
                 c.add_device(device)
     devicefound.send(device)
     callback(device)
 def _process_device(self, device):
     if isinstance(device, Switch):
         callback = self._switch_callback
         registry = self._switches
     elif isinstance(device, Motion):
         callback = self._motion_callback
         registry = self._motions
     elif isinstance(device, Bridge):
         callback = self._bridge_callback
         registry = self._bridges
         for light in device.Lights:
             log.info("Found light \"%s\" connected to \"%s\"" % (light, device.name))
         for group in device.Groups:
             log.info("Found group \"%s\" connected to \"%s\"" % (group, device.name))
     elif isinstance(device, Maker):
         callback = self._maker_callback
         registry = self._makers
     else:
         return
     self.devices[device.name] = device
     registry[device.name] = device
     if self._with_subscribers:
         self.registry.register(device)
         self.registry.on(device, 'BinaryState',
                          device._update_state)
     try:
         if isinstance(device, Bridge):
             pass
         else:
             device.ping()
     except DeviceUnreachable:
         return
     devicefound.send(device)
     callback(device)
Exemple #3
0
 def _process_device(self, device, cache=None):
     if isinstance(device, Switch):
         callback = self._switch_callback
         registry = self._switches
     elif isinstance(device, Motion):
         callback = self._motion_callback
         registry = self._motions
     elif isinstance(device, Maker):
         callback = self._maker_callback
         registry = self._makers
     else:
         return
     self.devices[device.name] = device
     registry[device.name] = device
     if self._with_subscribers:
         self.registry.register(device)
         self.registry.on(device, 'BinaryState', device._update_state)
     try:
         device.ping()
     except DeviceUnreachable:
         return
     else:
         if cache if cache is not None else self._with_cache:
             with get_cache() as c:
                 c.add_device(device)
     devicefound.send(device)
     callback(device)
Exemple #4
0
 def _process_device(self, device):
     if isinstance(device, Switch):
         callback = self._switch_callback
         registry = self._switches
     elif isinstance(device, Motion):
         callback = self._motion_callback
         registry = self._motions
     elif isinstance(device, Bridge):
         callback = self._bridge_callback
         registry = self._bridges
         for light in device.Lights:
             log.info("Found light \"%s\" connected to \"%s\"" % (light, device.name))
         for group in device.Groups:
             log.info("Found group \"%s\" connected to \"%s\"" % (group, device.name))
     elif isinstance(device, Maker):
         callback = self._maker_callback
         registry = self._makers
     else:
         return
     self.devices[device.name] = device
     registry[device.name] = device
     if self._with_subscribers:
         self.registry.register(device)
         self.registry.on(device, 'BinaryState',
                          device._update_state)
     try:
         if isinstance(device, Bridge):
             pass
         else:
             device.ping()
     except DeviceUnreachable:
         return
     devicefound.send(device)
     callback(device)