@ipaq62 wrote:
My script will turn on certain lights on my old lutron setup. Taken from my Vera installation. I don’t think I can use that in HA? I think I need to convert it to python. My try below the LUA Any hints is appreciated.
local socket = require “socket”
local lutron_tcpfunction connectLutron()
lutron_tcp = assert(socket.tcp())
lutron_tcp:settimeout(0.5)
lutron_tcp:connect(“192.168.0.50”, 23)
endfunction sendLutron(cmd)
lutron_tcp:send(cmd … “\r”)
sleepLutron()
endfunction disconnectLutron()
lutron_tcp:close()
endfunction sleepLutron()
luup.sleep(500)
endfunction powerOnLutron()
sendLutron(“password”)
sleepLutron()
endconnectLutron()
powerOnLutron()
sendLutron("#DEVICE,0x000b0eb9,141,7,0")
sendLutron("#DEVICE,0x000b11a7,141,7,0")
disconnectLutron()My try on Python:
import telnetlib
HOST = 192.168.0.50"
password = “nwk”
tn = telnetlib.Telnet(HOST, “23”)
tn.read_until(“login: “)
tn.write(password + “\n”)
tn.read_until(“connection established”)
tn.write(”#DEVICE,0x000b0eb9,141,7,0\n”)
tn.write("#DEVICE,0x000b11a7,141,7,0\n")
tn.write(“exit\n”)
tn.read_all()Pretty sure the exit part don’t work. Will try to see if I can test this outside HA first.
Thanks in advance!
Posts: 1
Participants: 1