teest
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 18:29:54 +01:00
parent ac0e14fd6b
commit b78cc4066a
2 changed files with 32 additions and 10 deletions

View file

@ -4,7 +4,7 @@ from app.utils import run_telnet_command
scheduler = APScheduler()
@scheduler.task('interval', id='do_periodic_serial_job', seconds=3)
@scheduler.task('interval', id='do_periodic_serial_job', seconds=4)
def periodic_serial_job():
print("Running Sync Job")
for powerbar in powerbars:
@ -27,9 +27,9 @@ def periodic_serial_job():
if on_command is not "On ":
print("Running On command")
# run_telnet_command(powerbar, on_command.rstrip(','))
run_telnet_command(powerbar, on_command.rstrip(','))
print(f"Turning off outlets: {off_command.rstrip(',')}")
if off_command is not "Off ":
print("Running Off command")
# run_telnet_command(powerbar, off_command.rstrip(','))
run_telnet_command(powerbar, off_command.rstrip(','))

View file

@ -92,6 +92,9 @@ def powerbar_control(powerbar, outlet, action):
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"{action} {outlet}")
if powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = action
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
@ -106,6 +109,10 @@ def powerbar_control(powerbar, outlet, action):
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"off {outlet}")
if powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
@ -114,6 +121,10 @@ def powerbar_control(powerbar, outlet, action):
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"on {outlet}")
if powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
@ -124,6 +135,10 @@ def powerbar_control(powerbar, outlet, action):
print(f"Turning Off powerbar {powerbar} outlet {outlet}")
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"off {outlet}")
if powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
@ -132,6 +147,10 @@ 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 powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
@ -219,6 +238,9 @@ def powebar_group_action(group, action):
if powerbars[powerbar]['method'] == "telnet":
command = run_telnet_command(powerbar,f"{action} {outlets}")
if powerbars[powerbar]['method'] == "batch_telnet":
command = True
if command:
for outlet in device['outlets']:
if outlet in powerbars[powerbar]['outlets']: