test
All checks were successful
Deploy powerbar.ti Frontend Portal / Deploy-Tinance2-Frontend-Portal-Production (push) Successful in 37s

This commit is contained in:
Matthew Frost 2024-02-07 16:44:32 +01:00
parent bcb97819f1
commit 63e957a5a6
2 changed files with 11 additions and 10 deletions

View file

@ -24,6 +24,7 @@ def run_telnet_command(powerbar, command):
for _ in range(retries):
try:
check_input_error(tn)
tn = get_telnet_connection(powerbar)
tn.write(f"{command}\r\n".encode('ascii'))
tn.close()

View file

@ -135,8 +135,8 @@ def powerbar_control(powerbar, outlet, action):
print(f"Turning On powerbar {powerbar} outlet {outlet}")
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"on {outlet}")
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
state = powerbars[powerbar]['outlets'][outlet].get('state', 'unknown')
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : state}, namespace='/powerupdates')
@ -220,15 +220,15 @@ def powebar_group_action(group, action):
print(f"Turning {action} powerbar {powerbar} outlet {outlets}")
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"{action} {outlets}")
if command:
for outlet in device['outlets']:
if outlet in powerbars[powerbar]['outlets']:
powerbars[powerbar]['outlets'][outlet]['state'] = action
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
print(f"Turned {action} powerbar {powerbar} outlet {outlet}")
return jsonify({'status': "200"})
if command:
for outlet in device['outlets']:
if outlet in powerbars[powerbar]['outlets']:
powerbars[powerbar]['outlets'][outlet]['state'] = action
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
print(f"Turned {action} powerbar {powerbar} outlet {outlet}")
return jsonify({'status': "200"})
return jsonify({'status': "500"})
except Exception as E: