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.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(','))
|
22
app/views.py
22
app/views.py
|
@ -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']:
|
||||
|
|
Loading…
Reference in a new issue