Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Need some assistance on my lua script-> python for lutron

$
0
0

@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 :slight_smile: Any hints is appreciated.

local socket = require “socket”
local lutron_tcp

function connectLutron()
lutron_tcp = assert(socket.tcp())
lutron_tcp:settimeout(0.5)
lutron_tcp:connect(“192.168.0.50”, 23)
end

function sendLutron(cmd)
lutron_tcp:send(cmd … “\r”)
sleepLutron()
end

function disconnectLutron()
lutron_tcp:close()
end

function sleepLutron()
luup.sleep(500)
end

function powerOnLutron()
sendLutron(“password”)
sleepLutron()
end

connectLutron()
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

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>