code: def _set(lamp_id, state, method="state"):
      '''
      Set state to the device by ID.
  
      :param lamp_id:
      :param state:
      :return:
      '''
      try:
          res = _query(lamp_id, state, action=method, method='PUT')
      except Exception as err:
          raise CommandExecutionError(err)
  
      res = len(res) > 1 and res[-1] or res[0]
      if res.get('success'):
          res = {'result': True}
      elif res.get('error'):
          res = {'result': False,
                 'description': res['error']['description'],
                 'type': res['error']['type']}
  
      return ref _set(lamp_id, state, method="state"):
      '''
      Set state to the device by ID.
  
      :param lamp_id:
      :param state:
      :return:
      '''
      try:
          res = _query(lamp_id, state, action=method, method='PUT')
      except Exception as err:
          raise CommandExecutionError(err)
  
      res = len(res) > 1 and res[-1] or res[0]
      if res.get('success'):
          res = {'result': True}
      elif res.get('error'):
          res = {'result': False,
                 'description': res['error']['description'],
                 'type': res['error']['type']}
  
      return res
docs: Set state to the device by ID.
  
      :param lamp_id:
      :param state:
      :return: