encode(options) {
    // Check command byte
    if (!Object.values(CommandType).includes(options.commandByte)) {
      throw new TypeError('Command byte not defined.');
    }

    // Convert Objects to Strings, Strings to Buffers
    if (!(options.data instanceof Buffer)) {
      if (typeof options.data !== 'string') {
        options.data = JSON.stringify(options.data);
      }

      options.data = Buffer.from(options.data);
    }

    if (this.version === '3.4') {
      return this._encode34(options);
    }

    if (this.version === '3.5') {
      return this._encode35(options);
    }

    return this._encodePre34(options);
  }
Encodes a payload into a Tuya-protocol-compliant packet.
@param {Object} options Options for encoding
@param {Buffer|String|Object} options.data data to encode
@param {Boolean} options.encrypted whether or not to encrypt the data
@param {Number} options.commandByte
command byte of packet (use CommandType definitions)
@param {Number} [options.sequenceN] optional, sequence number
@returns {Buffer} Encoded Buffer