code: async def _set_state(self, state: int) -> bool:
          
          try:
              set_state_resp = await self.api._request(
                  'put',
                  DEVICE_SET_ENDPOINT,
                  json={
                      'attributeName': 'desireddoorstate',
                      'myQDeviceId': self.device_id,
                      'AttributeValue': state,
                  })
          except RequestError as err:
              _LOGGER.error('%s: Setting state failed (and halting): %s',
                            self.name, err)
              return False
  
          if set_state_resp is None:
              return False
  
          if int(set_state_resp.get('ReturnCode', 1)) != 0:
              _LOGGER.error(
                  '%s: Error setting the device state: %s', self.name,
                  set_state_resp.get('ErrorMessage', 'Unknown Error'))
              return False
  
          return True
docs: Set the state of the device.