Spaces:
Sleeping
Sleeping
akshayballal
commited on
Commit
•
736c64e
1
Parent(s):
b911d24
chore: Update energy usage statistics display in dashboard.py
Browse files- dashboard.py +27 -3
- mqttpublisher.py +1 -2
dashboard.py
CHANGED
@@ -13,6 +13,10 @@ from src.rtu.RTUPipeline import RTUPipeline
|
|
13 |
from src.rtu.RTUAnomalizer1 import RTUAnomalizer1
|
14 |
from src.rtu.RTUAnomalizer2 import RTUAnomalizer2
|
15 |
import plotly.express as px
|
|
|
|
|
|
|
|
|
16 |
|
17 |
rtu_data_pipeline = RTUPipeline(
|
18 |
scaler1_path="src/rtu/models/scaler_rtu_1_2.pkl",
|
@@ -21,6 +25,8 @@ rtu_data_pipeline = RTUPipeline(
|
|
21 |
|
22 |
rtu_anomalizers = []
|
23 |
|
|
|
|
|
24 |
|
25 |
rtu_anomalizers.append(
|
26 |
RTUAnomalizer1(
|
@@ -368,9 +374,11 @@ with st.container():
|
|
368 |
|
369 |
# Energy Comsumption Statistics
|
370 |
with row2_row2_col2:
|
371 |
-
st.
|
372 |
-
|
373 |
-
|
|
|
|
|
374 |
) # ---- REPLACE WITH ACTUAL DATA ----
|
375 |
|
376 |
|
@@ -416,6 +424,7 @@ resid_placeholder = st.empty()
|
|
416 |
|
417 |
resid_vav_placeholder = st.empty()
|
418 |
|
|
|
419 |
|
420 |
while True:
|
421 |
|
@@ -452,6 +461,21 @@ while True:
|
|
452 |
fault_3 = None
|
453 |
fault_4 = None
|
454 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
df_new1, df_trans1, df_new2, df_trans2 = rtu_data_pipeline.fit(
|
456 |
pd.DataFrame(mqtt_client.data_list)
|
457 |
)
|
|
|
13 |
from src.rtu.RTUAnomalizer1 import RTUAnomalizer1
|
14 |
from src.rtu.RTUAnomalizer2 import RTUAnomalizer2
|
15 |
import plotly.express as px
|
16 |
+
import sys
|
17 |
+
import subprocess
|
18 |
+
|
19 |
+
# subprocess.run([f"{sys.executable}", "mqttpublisher.py"])
|
20 |
|
21 |
rtu_data_pipeline = RTUPipeline(
|
22 |
scaler1_path="src/rtu/models/scaler_rtu_1_2.pkl",
|
|
|
25 |
|
26 |
rtu_anomalizers = []
|
27 |
|
28 |
+
average_energy = 0
|
29 |
+
max_energy = 0
|
30 |
|
31 |
rtu_anomalizers.append(
|
32 |
RTUAnomalizer1(
|
|
|
374 |
|
375 |
# Energy Comsumption Statistics
|
376 |
with row2_row2_col2:
|
377 |
+
energy_stats_placeholder = {"box": st.empty(), "sub": st.empty()}
|
378 |
+
|
379 |
+
energy_stats_placeholder["box"].title("Energy Usage Statistics")
|
380 |
+
energy_stats_placeholder["sub"].text(
|
381 |
+
f"Average: {max_energy} kWh\nHighest: {average_energy} kWh"
|
382 |
) # ---- REPLACE WITH ACTUAL DATA ----
|
383 |
|
384 |
|
|
|
424 |
|
425 |
resid_vav_placeholder = st.empty()
|
426 |
|
427 |
+
k = 0
|
428 |
|
429 |
while True:
|
430 |
|
|
|
461 |
fault_3 = None
|
462 |
fault_4 = None
|
463 |
|
464 |
+
energy = (
|
465 |
+
pd.DataFrame(mqtt_client.data_list)["hvac_N"].item()
|
466 |
+
+ pd.DataFrame(mqtt_client.data_list)["hvac_N"].item()
|
467 |
+
)
|
468 |
+
k += 1
|
469 |
+
|
470 |
+
average_energy = average_energy + (energy - average_energy) / k
|
471 |
+
|
472 |
+
if energy > max_energy:
|
473 |
+
max_energy = energy
|
474 |
+
|
475 |
+
energy_stats_placeholder["sub"].text(
|
476 |
+
f"Average: {max_energy} kWh\nHighest: {average_energy} kWh"
|
477 |
+
) # ---- REPLACE WITH ACTUAL DATA ----
|
478 |
+
|
479 |
df_new1, df_trans1, df_new2, df_trans2 = rtu_data_pipeline.fit(
|
480 |
pd.DataFrame(mqtt_client.data_list)
|
481 |
)
|
mqttpublisher.py
CHANGED
@@ -5,10 +5,9 @@ import pandas as pd
|
|
5 |
import json
|
6 |
|
7 |
clientId = "smartbuilding"
|
8 |
-
broker_address = "test.
|
9 |
broker_port = 1883
|
10 |
|
11 |
-
|
12 |
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, clientId)
|
13 |
client.connect(broker_address, broker_port)
|
14 |
topic = "sensor_data"
|
|
|
5 |
import json
|
6 |
|
7 |
clientId = "smartbuilding"
|
8 |
+
broker_address = "test.mosquitto.org"
|
9 |
broker_port = 1883
|
10 |
|
|
|
11 |
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, clientId)
|
12 |
client.connect(broker_address, broker_port)
|
13 |
topic = "sensor_data"
|