![]() |
Blinds Control - Multiple Socket Connections Per Script - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Blinds Control - Multiple Socket Connections Per Script (/showthread.php?tid=2459) |
Blinds Control - Multiple Socket Connections Per Script - jamesng - 09.02.2020 Hi I'm trying to control Somfy blinds by issuing an UP or DOWN command followed by a STOP command a few seconds later to achieve a partially open blind. ie: to automatically open the blind 30%. I'm making a socket connection to the Somfy controller - this works fine - however I don't seem be able to send two separate commands over two socket connections from the one event-based script. The second sendCommand never gets sent. The controller is able to receive multiple commands ok when triggered from separate buttons / scripts within the same timeframe. Is there a different way to code this so that the LUA sends the second command? Thanks in advance Kind Regards James FUNCTION Code: function sendCommand(command) SCRIPT Code: BlindsTravel = 22; -- Time in seconds to fully open/close RE: Blinds Control - Multiple Socket Connections Per Script - Erwin van der Zwart - 09.02.2020 Hi, To close a command you probably need to send \r to be able to send the next, try to a add this into your sendcommand function '\x0D\x0A' .. '\r' BR, Erwin RE: Blinds Control - Multiple Socket Connections Per Script - jamesng - 09.02.2020 Hi Erwin, That still didn't work either .. the first command executes however the second one does not. Even in a really simple example, the second command doesn't execute with the added \r. For example Code: function sendCommand(command) If I split this into two separate scripts and run the first one, then the second one a second later the commands execute as expected - however if I call sendCommand twice from the same script, the second calls fails (and I never see 'Sleep 2' in the logs. Any idea why this would be happening? Kind Regards James RE: Blinds Control - Multiple Socket Connections Per Script - admin - 09.02.2020 '\x0D\x0A' is the same as '\r\n' so extra '\r' is not needed I think the problem might be with multiple connections which the gateway might not handle properly. Try sending two commands in the same connection: Code: sock = require("socket").tcp() RE: Blinds Control - Multiple Socket Connections Per Script - jamesng - 09.02.2020 Hi That seems to work. Many thanks! Kind Regards James |