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 that you accept these cookies being set.

Lutron send command
#1
Hi!
I have a project with Lutron integration and I follwed the thread below to setup LM.

https://forum.logicmachine.net/showthrea...ght=lutron

While LM successfully works as listener and I can see everry log from Lutron device and button,
any Lutron command that I send does not seem to be reaching and nothing will be shown in the log.

My event script is pretty simple as below. (I have lutron user script and resident script as shown in the forum thread above)
Code:
require('user.lutron')

tcp, err = lutron_login()
if not tcp then
  log('no connection to device', err)
end
tcp:send('#DEVICE,5001,1,3\r\n')

Other things that I tried;
・I used ping command of LM network utility and checked if LM can reach Lutron interface and it was successfull.
・I confirmed lutron_login function returns response "QNET>" which proves login to the Lutron interface is successful.
・I installed telnet command on my PC (which is located in the same network as LM) and tried executing Lutron commands and it was successful.

Could you think of any reason that I cannnot execute command from LM event script?
Reply
#2
Modify lutron_login() in the user library to log the data that is sent to LM.
Code:
function lutron_login()
  local tcp, tcp_err = lutron_connect()

  if not tcp then
    return nil, tcp_err
  end

  local res, err

  res, err = tcp:receive(7)
  log(res, err)
  
  tcp:send(user..'\r\n')
  
  res, err = tcp:receive(10)
  log(res, err)

  tcp:send(password..'\r\n')
  
  res, err = tcp:receive(9)
  log(res, err)

  if res == nil or res == 'bad login' then
    tcp:close()
    return nil, res
  end

  return tcp
end

Add log(lutron_receive(tcp)) at the end of your script to check the reply.
Reply
#3
Dear admin,
Appreciate your advice so much,
I am not sure what happened but when I added "lutron_receive(tcp)" at the end of the script everyting started to work!
Thank you so much for your advice as always!
Reply


Forum Jump: