Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

main -> dev #10

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# .streamlit/config.toml

# agile-home-dashboard
[server]
#headless = true # Run Streamlit in headless mode, ideal for cloud deployments
port = 8501 # Define the port for the Streamlit app
#enableCORS = false # Disable CORS if deploying within the same domain

[theme]
base= "dark"
primaryColor = "#3d405b"
backgroundColor = "#f4f1de"
secondaryBackgroundColor = "#b8d6c7"
textColor = "#3d405b"
base= "light"
primaryColor = "#B5146A" # slider colour
backgroundColor = "#FCFCFC"
secondaryBackgroundColor = "#7DBDF5" # side bar
textColor = "#261132"
font = "sans serif"


[browser]
gatherUsageStats = false # Disable collection of usage statistics for privacy
14 changes: 10 additions & 4 deletions Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import streamlit as st
import toml

from agile_home_dashboard import fetch_data
from agile_home_dashboard import fetch_data, load_css


# Load the TOML file
Expand All @@ -22,11 +22,17 @@ def load_config(file_path=".streamlit/config.toml"):
initial_sidebar_state="expanded",
)

plotMarkerColor = "#7DBDF5" # plot marker colour

config = load_config()
colors = config["theme"]
st.session_state.bg_color = colors["secondaryBackgroundColor"]
st.session_state.bg_color = colors["backgroundColor"]
st.session_state.font = colors["textColor"]
st.session_state.marker = colors["textColor"]
st.session_state.marker = plotMarkerColor
st.session_state.textBoxColor = "#2A69A1"
st.session_state.textColor = "#B5146A"

load_css()

if "api_key" not in st.session_state:
st.session_state.api_key = "" # Default value
Expand All @@ -37,7 +43,7 @@ def load_config(file_path=".streamlit/config.toml"):
api_key = st.session_state.api_key
st.session_state.df = fetch_data(api_key)

day_to_plot = st.selectbox("Select a day to plot:", ["Today", "Tomorrow"])
day_to_plot = st.radio("Select day:", options=["Today", "Tomorrow"], index=0)
if day_to_plot == "Today":
if st.session_state.df is None:
st.write("No data available for today.")
Expand Down
27 changes: 27 additions & 0 deletions agile_home_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,30 @@ def get_current_cost(df, current_time):
next_price = next_cost_row["value_inc_vat"]

return current_price, next_price, current_cost_row, next_cost_row


def load_css():
st.markdown(
f"""
<style>
/* Change the text color in the input field */
div[data-baseweb="input"] input {{
color: white;
background-color: {st.session_state.textBoxColor};
}}

/* Style the +/- buttons at the end of number input */
div[data-testid="stNumberInput"] button {{
color: white;
background-color: {st.session_state.textBoxColor};
}}

/* Optional: Change hover effect for buttons */
div[data-testid="stNumberInput"] button:hover {{
background-color: {st.session_state.textBoxColor};
color: white;
}}
</style>
""",
unsafe_allow_html=True,
)
9 changes: 6 additions & 3 deletions pages/Kettle_#.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import plotly.graph_objects as go
import streamlit as st

from agile_home_dashboard import get_current_cost, get_current_time
from agile_home_dashboard import get_current_cost, get_current_time, load_css


def calculate_kettle_cost(current_price, next_price, run_time, power):
Expand Down Expand Up @@ -124,14 +124,17 @@ def plot_kettle_timing():
st.plotly_chart(fig)


# Main application logic
color = "#B87272"
load_css()


def main():
st.title("Kettle # on Octopus Agile")
if st.session_state.df is not None:
st.write("How much does the kettle cost right now?")

run_time = st.number_input(
"Kettle run time [s]:", min_value=0, max_value=2000, value=137
"Kettle run time [s]:", min_value=0, max_value=10000, value=137
)
power = st.number_input(
"Kettle power [kW]:", min_value=0.0, max_value=1e8, value=2.1
Expand Down
4 changes: 3 additions & 1 deletion pages/Oven_#.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import streamlit as st

from agile_home_dashboard import get_current_cost, get_current_time
from agile_home_dashboard import get_current_cost, get_current_time, load_css

load_css()


def main():
Expand Down
4 changes: 3 additions & 1 deletion pages/Washing_Machine_#.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import pytz
import streamlit as st

from agile_home_dashboard import get_current_time
from agile_home_dashboard import get_current_time, load_css

load_css()


def calculate_drying_cost(dry_time, power, df, current_time):
Expand Down