teest
All checks were successful
Deploy powerbar.ti Frontend Portal / Deploy-Tinance2-Frontend-Portal-Production (push) Successful in 37s
All checks were successful
Deploy powerbar.ti Frontend Portal / Deploy-Tinance2-Frontend-Portal-Production (push) Successful in 37s
This commit is contained in:
parent
ac0e14fd6b
commit
b78cc4066a
2 changed files with 32 additions and 10 deletions
|
@ -4,7 +4,7 @@ from app.utils import run_telnet_command
|
||||||
|
|
||||||
scheduler = APScheduler()
|
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():
|
def periodic_serial_job():
|
||||||
print("Running Sync Job")
|
print("Running Sync Job")
|
||||||
for powerbar in powerbars:
|
for powerbar in powerbars:
|
||||||
|
@ -27,9 +27,9 @@ def periodic_serial_job():
|
||||||
|
|
||||||
if on_command is not "On ":
|
if on_command is not "On ":
|
||||||
print("Running On command")
|
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(',')}")
|
print(f"Turning off outlets: {off_command.rstrip(',')}")
|
||||||
if off_command is not "Off ":
|
if off_command is not "Off ":
|
||||||
print("Running Off command")
|
print("Running Off command")
|
||||||
# run_telnet_command(powerbar, off_command.rstrip(','))
|
run_telnet_command(powerbar, off_command.rstrip(','))
|
36
app/views.py
36
app/views.py
|
@ -92,6 +92,9 @@ def powerbar_control(powerbar, outlet, action):
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"{action} {outlet}")
|
command = run_telnet_command(powerbar,f"{action} {outlet}")
|
||||||
|
|
||||||
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
|
command = True
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = action
|
powerbars[powerbar]['outlets'][outlet]['state'] = action
|
||||||
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
|
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
|
||||||
|
@ -106,16 +109,24 @@ def powerbar_control(powerbar, outlet, action):
|
||||||
|
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"off {outlet}")
|
command = run_telnet_command(powerbar,f"off {outlet}")
|
||||||
if command:
|
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
|
command = True
|
||||||
time.sleep(5)
|
|
||||||
print(f"Turning On powerbar {powerbar} outlet {outlet}")
|
if command:
|
||||||
|
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
|
||||||
|
app.socketio.emit('power-event',{'powerbar': powerbar, 'outlet' : outlet, 'action' : action}, namespace='/powerupdates')
|
||||||
|
time.sleep(5)
|
||||||
|
print(f"Turning On powerbar {powerbar} outlet {outlet}")
|
||||||
|
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"on {outlet}")
|
command = run_telnet_command(powerbar,f"on {outlet}")
|
||||||
if command:
|
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
|
command = True
|
||||||
|
|
||||||
|
if command:
|
||||||
|
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
|
||||||
|
|
||||||
if action == 'toggle':
|
if action == 'toggle':
|
||||||
print(powerbars[powerbar]['outlets'][outlet]['state'])
|
print(powerbars[powerbar]['outlets'][outlet]['state'])
|
||||||
|
@ -124,6 +135,10 @@ def powerbar_control(powerbar, outlet, action):
|
||||||
print(f"Turning Off powerbar {powerbar} outlet {outlet}")
|
print(f"Turning Off powerbar {powerbar} outlet {outlet}")
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"off {outlet}")
|
command = run_telnet_command(powerbar,f"off {outlet}")
|
||||||
|
|
||||||
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
|
command = True
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
|
powerbars[powerbar]['outlets'][outlet]['state'] = "off"
|
||||||
|
|
||||||
|
@ -132,6 +147,10 @@ def powerbar_control(powerbar, outlet, action):
|
||||||
print(f"Turning On powerbar {powerbar} outlet {outlet}")
|
print(f"Turning On powerbar {powerbar} outlet {outlet}")
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"on {outlet}")
|
command = run_telnet_command(powerbar,f"on {outlet}")
|
||||||
|
|
||||||
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
|
command = True
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
|
powerbars[powerbar]['outlets'][outlet]['state'] = "on"
|
||||||
|
|
||||||
|
@ -219,6 +238,9 @@ def powebar_group_action(group, action):
|
||||||
if powerbars[powerbar]['method'] == "telnet":
|
if powerbars[powerbar]['method'] == "telnet":
|
||||||
command = run_telnet_command(powerbar,f"{action} {outlets}")
|
command = run_telnet_command(powerbar,f"{action} {outlets}")
|
||||||
|
|
||||||
|
if powerbars[powerbar]['method'] == "batch_telnet":
|
||||||
|
command = True
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
for outlet in device['outlets']:
|
for outlet in device['outlets']:
|
||||||
if outlet in powerbars[powerbar]['outlets']:
|
if outlet in powerbars[powerbar]['outlets']:
|
||||||
|
|
Loading…
Reference in a new issue