encodeOutgoingMiioPacket(payload, deviceId) {
        const stamp = this.stamp.orNew();
        let encryptedPayload;

        if (payload !== null) {
            const cipher = crypto.createCipheriv("aes-128-cbc", this.tokenKey, this.tokenIV);
            const payloadBuf = Buffer.from(JSON.stringify(payload),"utf8");

            encryptedPayload = Buffer.concat([
                cipher.update(payloadBuf),
                cipher.final()
            ]);
        } else {
            encryptedPayload = Buffer.alloc(0);
        }

        const secondsPassed = Math.max(0, Math.floor((Date.now() - stamp.time) / 1000));

        const header = createMiioHeader({
            timestamp: stamp.val + secondsPassed,
            deviceId: deviceId,
            payloadLength: encryptedPayload.length,
            unknown: 0
        });


        const calculatedChecksum = crypto.createHash("md5")
            .update(header.subarray(0, 16))
            .update(this.token)
            .update(encryptedPayload)
            .digest();

        calculatedChecksum.copy(header, 16);

        return Buffer.concat([header, encryptedPayload]);
    }
@param {any} payload
@param {number} deviceId
@returns {Buffer}