示例#1
0
 def factory(cls, unit_type, unit_identifier=None):
     subclass_dict = {clazz.model: clazz for clazz in cls.inheritors()}
     try:
         # TODO: remove copy pasta
         if unit_identifier is not None:
             return subclass_dict.get(unit_type.lower())(unit=unit_identifier)
         else:
             return subclass_dict.get(unit_type.lower())()
     except KeyError as e:
         LOGGER.warn('%s not a valid controller type', e)
    def start(self):
        try:
            g, r, b = self._config['g'], self._config['r'], self._config['b']
        except KeyError as e:
            LOGGER.warn('%s not found in config item: lighting_controller', e)
            return

        for device in self._devices:
            device.set_lighting(mode=RGB.Mode.RIPPLE,
                                speed=self._speed,
                                values=[g, r, b])
    def start(self):
        values = []
        try:
            g, r, b = self._config['g'], self._config['r'], self._config['b']
            for i in range(12):
                values.extend([g, r, b])
        except KeyError as e:
            LOGGER.warn('%s not found in config item: lighting_controller', e)

        for device in self._devices:
            device.set_lighting(mode=RGB.Mode.FULL, speed=0x00, values=values)
 def factory(cls, model, controller=None, port=None):
     subclass_dict = {
         clazz.model.lower(): clazz
         for clazz in cls.inheritors() if clazz.model is not None
     }
     try:
         dev = subclass_dict[model.lower()](controller, port)
         LOGGER.debug('created {} device'.format(dev.__class__.__name__))
         return dev
     except KeyError:
         LOGGER.warn(
             f'model {model} not found. controller: {controller} port: {port}'
         )
    def start(self):
        try:
            g, r, b = self._config['g'], self._config['r'], self._config['b']
        except KeyError as e:
            LOGGER.warn('%s not found in config item: lighting_controller', e)
            return

        for device in self._devices:
            values = []
            for i in range(12):
                values.extend([g, r, b])
            device.set_lighting(mode=RGB.Mode.PULSE,
                                speed=self._speed,
                                values=values)
 def factory(cls, config):
     subclass_dict = {clazz.model: clazz for clazz in cls.inheritors()}
     try:
         return subclass_dict.get(config.pop('model').lower())(config)
     except KeyError as e:
         LOGGER.warn('%s not found in config item', e)
示例#7
0
 def factory(cls, model, controller, port):
     subclass_dict = {clazz.model.lower(): clazz for clazz in cls.inheritors() if clazz.model is not None}
     try:
         return subclass_dict[model.lower()](controller, port)
     except KeyError:
         LOGGER.warn(f'model {model} not found. controller: {controller} port: {port}')