Posts: 94 
	Threads: 31 
	Joined: Feb 2022
	
 Reputation: 
 0
	 
 
	
	
		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?
	  
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 8423 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
 481
	 
 
	
	
		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.
	  
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 94 
	Threads: 31 
	Joined: Feb 2022
	
 Reputation: 
 0
	 
 
	
	
		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!
	 
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 75 
	Threads: 16 
	Joined: May 2021
	
 Reputation: 
 1
	 
 
	
		
		
		16.09.2024, 11:43 
(This post was last modified: 16.09.2024, 12:11 by Andrea Becagli.)
		
	 
	
		Hi everyone,  
I need to send commands e receive responses from a RA2 Select Lutron gateway. 
I currently use the Lutron library to log responses and errors of the TCP communication, but can not log in. 
 
This below is the output log from a event-based script.
 Code: Event for prova lutron cmd (1/1/1) 16.09.2024 13:36:20 
* arg: 1 
  * string: login:  
* arg: 2 
  * nil 
Event for prova lutron cmd (1/1/1) 16.09.2024 13:36:20 
* arg: 1 
  * string: password:  
* arg: 2 
  * nil 
Event for prova lutron cmd (1/1/1) 16.09.2024 13:36:50 
* arg: 1 
  * nil 
* arg: 2 
  * string: timeout 
Event for prova lutron cmd (1/1/1) 16.09.2024 13:36:50 
* arg: 1 
  * string: no connection to device 
* arg: 2 
  * nil
   
I copied and pasted the library without changing anything but IP and credentials. I am sure IP and credentials are correct because I tried copying and pasting them into Putty telnet service and I have no problem sending commands to the lutron device
	  
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 8423 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
 481
	 
 
	
	
		Try this modified function and post what you get in Logs: 
Code: function lutron_login() 
  local tcp, tcp_err = lutron_connect() 
 
  if not tcp then 
    return nil, tcp_err 
  end 
 
  local res, err 
 
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
   
  tcp:send(user..'\r\n') 
   
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
 
  tcp:send(password..'\r\n') 
   
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
 
  if res == nil or res == 'bad login' then  
    tcp:close() 
    return nil, res 
  end 
 
  return tcp 
end
  
	 
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 75 
	Threads: 16 
	Joined: May 2021
	
 Reputation: 
 1
	 
 
	
	
		 (16.09.2024, 11:57)admin Wrote:  Try this modified function and post what you get in Logs: 
Code: function lutron_login() 
  local tcp, tcp_err = lutron_connect() 
 
  if not tcp then 
    return nil, tcp_err 
  end 
 
  local res, err 
 
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
   
  tcp:send(user..'\r\n') 
   
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
 
  tcp:send(password..'\r\n') 
   
  res, err, partial = tcp:receive() 
  log(res, err, partial) 
 
  if res == nil or res == 'bad login' then  
    tcp:close() 
    return nil, res 
  end 
 
  return tcp 
end
  
So here is the log:
 Code: Event for prova lutron cmd (1/1/1) 16.09.2024 14:21:15 
* arg: 1 
  * nil 
* arg: 2 
  * string: timeout 
* arg: 3 
  * string: login:  
Event for prova lutron cmd (1/1/1) 16.09.2024 14:21:25 
* arg: 1 
  * nil 
* arg: 2 
  * string: timeout 
* arg: 3 
  * string: password:  
Event for prova lutron cmd (1/1/1) 16.09.2024 14:21:35 
* arg: 1 
  * nil 
* arg: 2 
  * string: timeout 
* arg: 3 
  * string: GNET>
  
	 
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 8423 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
 481
	 
 
	
	
		Replace all 3 log() calls with loghex() and try/post again.
	 
	
	
	
		
	 
 
 
	
	
	
		
	Posts: 75 
	Threads: 16 
	Joined: May 2021
	
 Reputation: 
 1
	 
 
	
		
		
		16.09.2024, 12:35 
(This post was last modified: 16.09.2024, 12:54 by Andrea Becagli.)
		
	 
	
		I now get what the problem was in the last function after the password was sent I waited for tcp:receive(9) but it only responded with 5 (GNET>)characters so it always gave back the timeout error and with res being nil the function always returned nil. 
 
Thanks admin you made me realise what the problem was 
  
Now new problem, is there a way I can avoid logging in every time I send a command?
	
	
	
	
		
	 
 
 
	 
 |