jangxx / node-magichome

An incomplete implementation of the functionality of the "Magic Home" app. Partially a port of https://github.com/Danielhiversen/flux_led to Node.js
ISC License
124 stars 26 forks source link

timeoutproblem #41

Closed ArtichautDev closed 2 years ago

ArtichautDev commented 2 years ago

Hi my peogram crash for timeout .... i use your module for sync my device razer with my led strip error : C:\Users\pierr\Documents\Chroma\node_modules\magic-home\lib\Control.js:210 reject(new Error("Command timed out")); ^

Error: Command timed out at Control._handleCommandTimeout (C:\Users\pierr\Documents\Chroma\node_modules\magic-home\lib\Control.js:210:12) at Timeout._onTimeout (C:\Users\pierr\Documents\Chroma\node_modules\magic-home\lib\Control.js:237:12) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)

my code : const Chroma = require("razer-chroma-nodejs"); let currentColor;

const { Control, CustomMode } = require('magic-home'); let light = new Control("192.168.0.103");

/ Create effect / const waveEffect = () => { Chroma.effects.keyboard.wave(0, 5);

return setInterval(() => {
    const cellData = Chroma.effects.keyboard.getData();

    currentColor = cellData[cellData.length - 1];

    Chroma.effects.headset.setEffect("CHROMA_CUSTOM", [cellData[0].getColor(), cellData[cellData.length - 1].getColor(), 0, 0, 0]);
    Chroma.effects.mouse.setColor(cellData[cellData.length - 1].getColor());
    Chroma.effects.chromalink.setColor(cellData[cellData.length - 1].getColor());
}, 1);

};

light.setPower(true).then(success => { // Load Chroma Chroma.util.init(() => { let effect = waveEffect();

    let ledEffect = setInterval(() => {
        light.setColor(currentColor.r, currentColor.g, currentColor.b);
    }, 70);

    setTimeout(() => {
        clearInterval(effect);
        clearInterval(ledEffect);
        Chroma.util.close();
    }, 10000);
});

});

jangxx commented 2 years ago

Please stop creating issues about questions about your own code, this is not what issues are for.

jangxx commented 2 years ago

Also please take a look at this: https://github.com/jangxx/node-magichome/wiki/Understanding-the-ack-parameter