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.

LM Lutron telnet listener
#1
hello everyone!!

I made function (with Admin's big help), which will show you what Lutron send by telnet
I have lutron Homework QS

create user libruary "lutron"
Code:
local socket = require("socket")

local user = 'default'
local password = 'default'

function lutron_connect()
    local tcp = assert(socket.tcp())
 tcp:settimeout(31)
    local res, err = tcp:connect('192.168.0.105', 23)
 if res then
   return tcp
 else
   tcp:close()
   return nil, err
 end
end

function lutron_login()
 local tcp, tcp_err = lutron_connect()
 if not tcp then
   return nil,  tcp_err
 end
 tcp:receive(7)
 tcp:send(user..'\r\n')
    tcp:receive(10)
 tcp:send(password..'\r\n')
 local res = tcp:receive(9)
 if res == nil or res == 'bad login' then
   tcp:close()
   return nil, res
 end
 return tcp
end
 
function lutron_receive(tcp)
res, err = tcp:receive()
 if not res then
   tcp:close()
   return nil, err
 end
 return res
end

and resident script
Code:
require('user.lutron')
 
tcp, err = lutron_login()
if not tcp then
 log('no connection to device', err)
end
while tcp do
 res, err = lutron_receive(tcp)
 log(res,err)
   if (res == nil) then
     return
   end
end
Reply
#2
some additions for that case
Lutron message parser
For example I shall show you how to receive setpoint temperature from Lutron panel/switch
Let’s write all messages from Lutron to knx group address
Change resident script
Code:
require('user.lutron')
 
tcp, err = lutron_login()
if not tcp then
 log('no connection to device', err)
end
while tcp do
 res, err = lutron_receive(tcp)
 --log(res,err)
   if (res == nil) then
     return
    else
      grp.write('15/1/1', res)
   end
end
From Lutron we receive a lot of messages when we change setpoint
For example, this 4 message we will receive twice, when we will change setpoint:
~HVAC,11,78,26,26 – i dont know what is it
~HVAC,11,18,79,0,0 – setpoint in Fahrenheit
~HVAC,11,19,26,0,0 -- setpoint in Celsius degree
~HVAC,11,10,26,26 -- i dont know what is it
 
Let’s see, what we have in  setpoint in Celsius degree
~HVAC,11,19,26,0,0
~HVAC – status from device
11 – device id, which send this message
19 – type of information (Celsius degree in this example)
26 - Celsius degree
0,0 – some other parameters
To parse this message and write temperature to knx address create event based script for message group address (15/1/1)
Code:
--lutron parser
-- get string
temp = event.getvalue()
-- convert sting to table
temp = string.split(temp, ',')
-- if comand type is ~HVAC let's move forward
if temp[1] == '~HVAC' then
    -- if device id = id of our panel let's move forward
    if temp[2] == '11' then -- be carefull, temp[2] is string, not number
        -- if in message is celsius degree
        if temp[3] == '19' then
            -- convert temperature from string to number
            temp = tonumber(temp[4])
            -- check current value of setpoint, to not to write the same value
            cur_temp = grp.getvalue('lutron_temp_setpoint')
            if temp~=cur_temp then
                -- write walue to temp address
                grp.write('lutron_temp_setpoint', temp)
            end
        end
    end
end
To write value from LM to Lutron create event script for setpoint object

Code:
require('user.lutron')
value = event.getvalue()
-- round setmoint to integer
value = math.floor(value)  
tcp, err = lutron_login()
if not tcp then
 log('no connection to device', err)
end
tcp:send('#HVAC,11,19,'..value..',0,0\r\n')
to read some data from lutron use next script (resident in my case)
Code:
require('user.lutron')

--Подключаемся и делаем запрос
tcp, err = lutron_login()
if not tcp then
 log('no connection to device', err)
else
  -- send some request
 tcp:send('?HVAC,11,15\r\n')
  -- and receive answer
 x = tcp:receive()
  -- log answer, or write it to message address
 log(x)
 tcp:close()
end
Reply
#3
Hi AEK,

We did this Lutron link 2 years ago on a big project.

Keep in mind to send a telegam once every x period otherwise the TCP connection will be closed (after 12 hours i believe) by Lutron.

We included a mechanisme to request date or time every hour from the Lutron server to keep the connection alive.

BR,

Erwin
Reply
#4
(12.10.2016, 14:15)Erwin van der Zwart Wrote: Hi AEK,

We did this Lutron link 2 years ago on a big project.

Keep in mind to send a telegam once every x period otherwise the TCP connection will be closed (after 12 hours i believe) by Lutron.

We included a mechanisme to request date or time every hour from the Lutron server to keep the connection alive.

BR,

Erwin

Hi, Erwin!
thanks for your advice.
there will be request of current temperature every N minutes in our case, so I think there will be no problem.

if you did this 2 years ago, could you post your code here to?
I'm not programmer, so i understand my code only partially Smile
Reply
#5
Hi Erwin,
is it possible to have some suggestion about Lutron integration? In the next week I will have to integrate it.
Let me know if it could be possible.
Thanks.
Reply


Forum Jump: