This commit is contained in:
Matthew Frost 2023-11-19 01:12:57 +01:00
parent 0e81584871
commit 169894dfc3

View file

@ -47,6 +47,7 @@ def powerbar_control(powerbar, outlet, action):
if action == 'on':
# Telnet to powerbar and send command
try:
print(f"Turning on powerbar {powerbar} outlet {outlet}")
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
tn.write(f"on {outlet}\r\n".encode('ascii'))
tn.close()
@ -59,6 +60,7 @@ def powerbar_control(powerbar, outlet, action):
if action == 'off':
# Telnet to powerbar and send command
try:
print(f"Turning off powerbar {powerbar} outlet {outlet}")
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
tn.write(f"off {outlet}\r\n".encode('ascii'))
tn.close()