w42 with optimizer result, wip

This commit is contained in:
Chris Oloff 2025-11-19 14:54:28 +02:00
parent 8e27fa8ff5
commit 47b5263874

View file

@ -20,6 +20,8 @@ class LoadForecast(BaseModel):
class SystemState(BaseModel):
load_forecast: LoadForecast = LoadForecast()
now: datetime = datetime.now()
state: SystemState = panel.rx(lambda s: SystemState.model_validate(s) if s else SystemState())(w42_state)
@ -38,6 +40,15 @@ def load_fc_chart(state: SystemState) -> dict:
slots = state.load_forecast.slots
at = state.load_forecast.at
return {
'title': {
'text': '24hr Forecast'
},
'legend': {
'data': ['Load Forecast']
},
'tooltip': {
'trigger': 'axis'
},
'xAxis': {
'type': 'category',
'data': [get_label(at, i) for i in range(len(slots))]
@ -46,6 +57,7 @@ def load_fc_chart(state: SystemState) -> dict:
'type': 'value'
},
'series': [{
'name': 'Load Forecast',
'data': slots,
'type': 'line'
}]
@ -53,6 +65,7 @@ def load_fc_chart(state: SystemState) -> dict:
load_fc_chart_rx = panel.rx(load_fc_chart)(state)
datetime_fmt = "%Y-%m-%d %H:%M:%S"
value = w42_state.rx.value
@ -66,7 +79,7 @@ _ = panel.template.FastListTemplate(
sizing_mode='stretch_width',
height=400
),
load_fc_chart_rx,
panel.pane.Markdown(panel.bind(lambda s: f"Load Forecast Time: {s.load_forecast.at}", state), sizing_mode='stretch_width'),
w42_state,
panel.pane.Markdown(panel.bind(lambda s: f"State at {s.now.strftime(datetime_fmt)}, Load Forecast Time: {s.load_forecast.at}", state), sizing_mode='stretch_width'),
],
).servable()