code: def set_value(self, qsid, new):
          # Set value & encode new to be passed to QSUSB
          
          try:
              dev = self[qsid]
          except KeyError:
              raise KeyError("Device {} not found".format(qsid))
          if new < 0:
              new = 0
          if new == dev.value:
              return
  
          if dev.is_dimmer:
              new = _MAX if new > (_MAX * .9) else new
          else:  # QSType.relay and any other
              new = _MAX if new > 0 else 0
  
          def success():
              """Success closure to update value."""
              self[qsid].value = new
              _LOGGER.debug("set success %s=%s", qsid, new)
              self._cb_value_changed(self, qsid, new)
  
          newqs = round(math.pow(round(new / _MAX * 100), 1 / self.dim_adj))
          _LOGGER.debug("%s hass=%s --> %s", qsid, new, newqs)
          self._cb_set_qsvalue(qsid, newqs, success)
docs: Set a value.