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
#1
Hi,

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.
Reply
#2
Do you have some description the legrand interface?
Reply
#3
Hi,
We connected via f455 Legrand IP interface.
We used some Legrand softwares called Scenarx. https://www.myhome-project.it/software/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 https://github.com/openwebnet . 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.
Regards,
Reply
#4
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.
Reply
#5
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.
Regards,
Reply
#6
Maybe you are missing additional \r\n after the command?
Reply
#7
Hi,
You can find some videos with putty connection.

https://www.youtube.com/watch?v=O2d_abVaqe0
https://www.youtube.com/watch?v=qDQftLB25Hc

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

  sock:settimeout(1)

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

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

  os.sleep(1)
  sock:send(cmd .. eot)

  os.sleep(1)
  sock:close()

  return true
end

openwebnetcmd('192.168.1.1', '*1*1*11##')
Reply
#9
Hi,

With a little change, it worked well.
Thank you very much.
Reply
#10
Hello,
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.

Regards,
Reply


Forum Jump: