test
All checks were successful
Deploy powerbar.ti Frontend Portal / Deploy-Tinance2-Frontend-Portal-Production (push) Successful in 6s
All checks were successful
Deploy powerbar.ti Frontend Portal / Deploy-Tinance2-Frontend-Portal-Production (push) Successful in 6s
This commit is contained in:
parent
26fd0eb802
commit
113cefbe82
1 changed files with 3 additions and 2 deletions
|
@ -166,18 +166,19 @@ def powebar_group_action(group, action):
|
||||||
|
|
||||||
if action in ['on', 'off']:
|
if action in ['on', 'off']:
|
||||||
try:
|
try:
|
||||||
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
|
|
||||||
for device in group["devices"]:
|
for device in group["devices"]:
|
||||||
powerbar = device["powerbar"]
|
powerbar = device["powerbar"]
|
||||||
|
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
|
||||||
print(f"Powerbar: {powerbar}")
|
print(f"Powerbar: {powerbar}")
|
||||||
outlets = ",".join([str(x) for x in device['outlets']])
|
outlets = ",".join([str(x) for x in device['outlets']])
|
||||||
print(f"Turning {action} powerbar {powerbar} outlet {outlets}")
|
print(f"Turning {action} powerbar {powerbar} outlet {outlets}")
|
||||||
tn.write(f"{action} {outlets}\r\n".encode('ascii'))
|
tn.write(f"{action} {outlets}\r\n".encode('ascii'))
|
||||||
|
tn.close()
|
||||||
for outlet in outlets:
|
for outlet in outlets:
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = action
|
powerbars[powerbar]['outlets'][outlet]['state'] = action
|
||||||
print(f"Turned {action} powerbar {powerbar} outlet {outlet}")
|
print(f"Turned {action} powerbar {powerbar} outlet {outlet}")
|
||||||
|
|
||||||
tn.close()
|
|
||||||
return jsonify({'status': "200"})
|
return jsonify({'status': "200"})
|
||||||
except Exception as E:
|
except Exception as E:
|
||||||
print(f"Telnet error: {E}")
|
print(f"Telnet error: {E}")
|
||||||
|
|
Loading…
Reference in a new issue