Skip to content

Commit

Permalink
Included the temperature tab and removed the power_function that belo…
Browse files Browse the repository at this point in the history
…nged to post_man
  • Loading branch information
eolus87 committed Jul 7, 2023
1 parent 18af601 commit d921283
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
36 changes: 18 additions & 18 deletions layout/temperature_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
styles = load_yaml(os.path.join("assets", "styles.yaml"))

# User configuration
update_interval_ms = 2050
update_interval_ms = 30050

# Initialization
power_tab = dcc.Tab(label='Temperature',
style=styles["tab_style"],
selected_style=styles["tab_selected_style"], children=[
# # Interval for automatic updates
# dcc.Interval(
# id='interval_refresh_temperature',
# interval=update_interval_ms,
# n_intervals=0
# ),
#
# # Title and Graph
# html.H2(children="Temperature [C]",
# style={'textAlign': 'center',
# 'color': '#FFFFFF'}
# ),
# dcc.Graph(id='temperature_graph'),
])
temperature_tab = dcc.Tab(label='Temperature',
style=styles["tab_style"],
selected_style=styles["tab_selected_style"], children=[
# Interval for automatic updates
dcc.Interval(
id='interval_refresh_temperature',
interval=update_interval_ms,
n_intervals=0
),

# Title and Graph
html.H2(children="Temperature [C]",
style={'textAlign': 'center',
'color': '#FFFFFF'}
),
dcc.Graph(id='temperature_graph'),
])
31 changes: 30 additions & 1 deletion main_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from power.powerdevicetype import PowerDeviceType
from layout.ping_tab import ping_tab
from layout.power_tab import power_tab
from layout.temperature_tab import temperature_tab

# User configuration
configuration_path = os.path.join("config", "config.yaml")
Expand All @@ -39,6 +40,10 @@
sensor_type = "power"
power_data_extractor = DataExtractor(sensor_type, configuration[sensor_type], querier)

# Initilization temperature
sensor_type = "temp"
temperature_data_extractor = DataExtractor(sensor_type, configuration[sensor_type], querier)

# Dash layout
app = Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(style={'backgroundColor': '#111111'},
Expand All @@ -48,7 +53,8 @@
'color': '#FFFFFF'}),
dcc.Tabs([
ping_tab,
power_tab
power_tab,
temperature_tab
])
])

Expand Down Expand Up @@ -150,6 +156,29 @@ def stream_fig_power(value):
return fig


@app.callback(
Output(component_id='temperature_graph', component_property='figure'),
Input(component_id='interval_refresh_temperature', component_property="n_intervals")
)
def stream_fig_temperature(value):
# Retrieve data
dfs_dict = temperature_data_extractor.retrieve_type_data(
[1],
configuration["hours_to_display"])
fig = go.Figure()
# Plot
for df_index, df_name in enumerate(dfs_dict):
fig.add_trace(go.Scatter(x=dfs_dict[df_name].index, y=dfs_dict[df_name]["value"],
name=df_name))
fig.update_layout(
xaxis_title="Date and Time",
yaxis_title="Temperature [C]",
template="plotly_dark",
margin=dict(t=5, b=5),
yaxis={"rangemode": "nonnegative"}
)
return fig

# @app.callback(
# Output(component_id='output-container-button', component_property='children'),
# [Input(component_id='button-example-1', component_property='n_clicks')],
Expand Down
29 changes: 0 additions & 29 deletions power/power_function.py

This file was deleted.

0 comments on commit d921283

Please sign in to comment.