This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

TCP Socket Connection for Legrand

We have Legrand system that we can send commands via TCP Socket. 

IP Address : 192.168.161
Port : 20000
Password : 12345 

On Command : *1*1*11##
Off Command : *1*0*11##

I tried to use some TCP socket examples in here but i failed. Can you help me for script regarding to information above.
Do you have some description the legrand interface?
We connected via f455 Legrand IP interface.
We used some Legrand softwares called Scenarx.
Via this software, we send Light on Command *1*1*11## and Light Off Command *1*0*11## and communicatin is worked.
Legrand system send commands via Open WebNet protocol based on TCP Socket communication.
There are open resources for openwebnet in here . One is Java Client. You can see the communication example via Java.
One of the our competitor in this project make connection with this Java Client example. But we want to use LM and Luascript. We heard that our competitor just send simple tcp socket commands but via Java.
At least try connecting via telnet using Putty or similar client from your PC. Since there's a password specified some extra protocol implementation is required.
Hi there ,
I will try. But if there is no password, can you write a simple script which connect to 192.168.161 address and 20000 port then it will send *1*1*11## code if the value is true.
Maybe you are missing additional \r\n after the command?
You can find some videos with putty connection.

Can you write an example script considering there is no password .
This is not a proper protocol implementation, but see if this works for you:
function openwebnetcmd(ip, cmd)
  local socket = require('socket')
  local eot = string.char(4)
  local sock = socket.tcp()


  local res, err = sock:connect(ip, 20000)
  if not res then
    alert('connect failed ' .. tostring(err))

  sock:send('*99*0##' .. eot)

  sock:send(cmd .. eot)


  return true

openwebnetcmd('', '*1*1*11##')

With a little change, it worked well.
Thank you very much.
As I said before above, sending command is working. Now I need to listen status information. For getting status,
I send *99*1## command first ,
Then I send *1*11## command. It means, I request status information for light address 11.
In putty, we get information like *1*1*11## .
In logic machine, how can i write this feedback in to a variable (Like value ) in script.


Forum Jump: