Compare commits

...

6 Commits

Author SHA1 Message Date
c4fd8b2cfd fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 14:51:56 +01:00
37ce3d47ca fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 14:41:18 +01:00
988f24994b fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 14:28:24 +01:00
b8dd70e5ae fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 14:20:09 +01:00
6ba9352edc second graph
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 14:13:30 +01:00
aaa23a9839 only one graph
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-28 13:54:11 +01:00

View File

@ -40,11 +40,12 @@ def index():
try: try:
dbh = psycopg.connect() dbh = psycopg.connect()
engine = sqlalchemy.create_engine("postgresql+psycopg://", creator=lambda: dbh) engine = sqlalchemy.create_engine("postgresql+psycopg://", creator=lambda: dbh)
df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM pv_energy_by_month", con=engine) df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM pv_energy_by_month", con=engine)
fig = px.bar(df, x='month', y='value', color='year', barmode='group') fig_1 = px.bar(df, x='month', y='value', color='year', barmode='group')
fig.update_layout( fig_1.update_layout(
title="Jahreswerte Exportierte Energie", title="Jahreswerte Exportierte Energie",
xaxis_title="Monat", xaxis_title="",
yaxis_title="", yaxis_title="",
legend_title="Jahr", legend_title="Jahr",
xaxis=dict( xaxis=dict(
@ -54,8 +55,27 @@ def index():
), ),
yaxis=dict(ticksuffix=" kWh") yaxis=dict(ticksuffix=" kWh")
) )
graph_html = fig.to_html(full_html=False) graph_html_1 = fig_1.to_html(full_html=False, default_height='33%')
graph_html_2 = fig.to_html(full_html=False)
df = pd.read_sql("SELECT time_bucket('5 minutes', time) AS bucket, AVG(power) AS avg_power FROM pv_power_v WHERE time >= date_trunc('day', now()) - '1 day'::interval AND time < date_trunc('day', now()) GROUP BY bucket ORDER BY bucket", con=engine)
fig_2 = px.line(df, x='bucket', y='avg_power')
fig_2.update_layout(
xaxis_title="",
yaxis_title="",
title="Export gestern",
yaxis=dict(ticksuffix=" W")
)
graph_html_2 = fig_2.to_html(full_html=False, default_height='33%')
df = pd.read_sql("SELECT time_bucket('5 minutes', time) AS bucket, AVG(power) AS avg_power FROM pv_power_v WHERE time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval GROUP BY bucket ORDER BY bucket", con=engine)
fig_3 = px.line(df, x='bucket', y='avg_power')
fig_3.update_layout(
xaxis_title="",
yaxis_title="",
title="Export heute",
yaxis=dict(ticksuffix=" W")
)
graph_html_3 = fig_3.to_html(full_html=False, default_height='33%')
return render_template_string(f""" return render_template_string(f"""
<html> <html>
@ -63,8 +83,9 @@ def index():
<title>Jahreswerte PV-Energie</title> <title>Jahreswerte PV-Energie</title>
</head> </head>
<body> <body>
{graph_html} {graph_html_1}
{graph_html_2} {graph_html_2}
{graph_html_3}
</body> </body>
</html> </html>
""") """)