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.

LM Lutron telnet listener
#11
Try this, no guarantees that it will work because we don't have any Lutron devices to test. Check Logs for any errors if the script does not work.
Adjust each query call as needed. First argument is the query request (without \r\n, it's added automatically), second argument is the status group address where the new value is written.
Code:
require('user.lutron')

sock, err = lutron_login()
if not sock then
  log('no connection to device', err)
  os.sleep(5)
end

function close(err)
  sock:close()
  sock = nil

  log('receive failed', err)
end

function query(req, out)
  if not sock then
    return
  end

  sock:send(req .. '\r\n')
  local res, err = sock:receive()

  if not res then
    return close(err)
  end

  if res:sub(1, 1) ~= '~' then
    return close('invalid reply ' .. res)
  end

  if res:sub(2, #req) ~= req:sub(2) then
    return close('invalid reply ' .. res)
  end

  local val = res:sub(#req + 2)
  val = tonumber(val)

  if val then
    grp.checkupdate(out, val)
  end
end

while sock do
  query('?DEVICE,10,6,3', '1/1/1')
  query('?DEVICE,10,1,2', '1/1/2')
  query('?DEVICE,10,3,4', '1/1/3')

  if sock then
    os.sleep(5) -- delay between each poll cycle
  else
    break
  end
end
Reply


Messages In This Thread
LM Lutron telnet listener - by AEK - 06.10.2016, 13:18
RE: LM Lutron telnet listener - by AEK - 12.10.2016, 12:07
RE: LM Lutron telnet listener - by AEK - 13.10.2016, 06:51
RE: LM Lutron telnet listener - by imprashant - 14.11.2022, 16:13
RE: LM Lutron telnet listener - by admin - 14.11.2022, 16:36
RE: LM Lutron telnet listener - by imprashant - 20.11.2022, 08:13
RE: LM Lutron telnet listener - by admin - 21.11.2022, 08:12
RE: LM Lutron telnet listener - by imprashant - 22.11.2022, 12:05
RE: LM Lutron telnet listener - by admin - 22.11.2022, 12:29
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 09:50
RE: LM Lutron telnet listener - by admin - 29.11.2022, 10:14
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 10:24
RE: LM Lutron telnet listener - by admin - 29.11.2022, 10:35
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 10:49
RE: LM Lutron telnet listener - by admin - 29.11.2022, 11:01
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 11:14
RE: LM Lutron telnet listener - by admin - 29.11.2022, 11:16
RE: LM Lutron telnet listener - by imprashant - 29.11.2022, 11:31
RE: LM Lutron telnet listener - by imprashant - 20.01.2023, 08:58
RE: LM Lutron telnet listener - by admin - 23.01.2023, 08:09

Forum Jump: