Hexagon / node-telldus

Node bindings for telldus-core
Other
34 stars 10 forks source link

Sending two commands at the same time #64

Closed jdagerot closed 8 years ago

jdagerot commented 9 years ago

I don't know if this is an issue for node-telldus or if if it's the core. However if I want to turnon two devices at the same time the last device wont react. I'm running this on a Raspberry Pi.

None of my recievers are trained with my wall mounted senders, instead eveything is handled by my server script. This means that when a sender is triggered my server will first recieve the code for the button and then send out turnOn/turnOff to the devices.

Code:

telldus.turnOnSync(13);
telldus.turnOnSync(14); // This will never happen

I've tried this aswell:

telldus.turnOn(13,function(){
    telldus.turnOn(14, function(){
        console.log("14 turned on");
    });
});

The only, somewhat, working solution is to set a timeOut like this:

console.log("Turning off 14...");
telldus.turnOff(14, function(err){
    console.log("err: " + err);
        setTimeout(function(){
            telldus.turnOff(13, function(err){
                console.log("err: " + err);
                console.log("13 turned off");
                });                             
        }, 2000);
});
Hexagon commented 8 years ago

Have pushed a possible solution for this, where i apply a mutex on all calls to telldus core. Reopening until verified.