groups
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
de462c95bb
commit
bca654612c
1 changed files with 6 additions and 5 deletions
11
app/views.py
11
app/views.py
|
@ -187,14 +187,15 @@ def powebar_group_action(powerbar, group, action):
|
|||
|
||||
if action in ['on', 'off']:
|
||||
try:
|
||||
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
|
||||
outlets = ",".join([str(x) for x in group['outlets']])
|
||||
print(f"Turning {action} powerbar {powerbar} outlet {outlets}")
|
||||
tn.write(f"{action} {outlets}\r\n".encode('ascii'))
|
||||
tn.close()
|
||||
|
||||
for outlet in group['outlets']:
|
||||
print(f"Turning {action} powerbar {powerbar} outlet {outlet}")
|
||||
tn = telnetlib.Telnet(powerbars[powerbar]['host'], powerbars[powerbar]['port'])
|
||||
tn.write(f"{action} {outlet}\r\n".encode('ascii'))
|
||||
tn.close()
|
||||
powerbars[powerbar]['outlets'][outlet]['state'] = action
|
||||
print(f"Turned {action} powerbar {powerbar} outlet {outlet}")
|
||||
time.sleep(1)
|
||||
|
||||
return jsonify({'status': "200"})
|
||||
except Exception as E:
|
||||
|
|
Loading…
Reference in a new issue