mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-03-12 17:46:18 +00:00
fix: logging, prediction update, multiple bugs (#584)
Some checks failed
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Some checks failed
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
* Fix logging configuration issues that made logging stop operation. Switch to Loguru logging (from Python logging). Enable console and file logging with different log levels. Add logging documentation. * Fix logging configuration and EOS configuration out of sync. Added tracking support for nested value updates of Pydantic models. This used to update the logging configuration when the EOS configurationm for logging is changed. Should keep logging config and EOS config in sync as long as all changes to the EOS logging configuration are done by set_nested_value(), which is the case for the REST API. * Fix energy management task looping endlessly after the second update when trying to update the last_update datetime. * Fix get_nested_value() to correctly take values from the dicts in a Pydantic model instance. * Fix usage of model classes instead of model instances in nested value access when evaluation the value type that is associated to each key. * Fix illegal json format in prediction documentation for PVForecastAkkudoktor provider. * Fix documentation qirks and add EOS Connect to integrations. * Support deprecated fields in configuration in documentation generation and EOSdash. * Enhance EOSdash demo to show BrightSky humidity data (that is often missing) * Update documentation reference to German EOS installation videos. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ from typing import Any, Optional, Union
|
||||
|
||||
import requests
|
||||
from fasthtml.common import Select
|
||||
from loguru import logger
|
||||
from monsterui.foundations import stringify
|
||||
from monsterui.franken import ( # Select, TODO: Select from FrankenUI does not work - using Select from FastHTML instead
|
||||
H3,
|
||||
@@ -29,13 +30,10 @@ from monsterui.franken import ( # Select, TODO: Select from FrankenUI does not
|
||||
)
|
||||
from platformdirs import user_config_dir
|
||||
|
||||
from akkudoktoreos.core.logging import get_logger
|
||||
from akkudoktoreos.server.dash.components import Error, Success
|
||||
from akkudoktoreos.server.dash.configuration import get_nested_value
|
||||
from akkudoktoreos.utils.datetimeutil import to_datetime
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# Directory to export files to, or to import files from
|
||||
export_import_directory = Path(user_config_dir("net.akkudoktor.eosdash", "akkudoktor"))
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ def ConfigCard(
|
||||
value: str,
|
||||
default: str,
|
||||
description: str,
|
||||
deprecated: Optional[Union[str, bool]],
|
||||
update_error: Optional[str],
|
||||
update_value: Optional[str],
|
||||
update_open: Optional[bool],
|
||||
@@ -118,6 +119,7 @@ def ConfigCard(
|
||||
value (str): The current value of the configuration.
|
||||
default (str): The default value of the configuration.
|
||||
description (str): A description of the configuration.
|
||||
deprecated (Optional[Union[str, bool]]): The deprecated marker of the configuration.
|
||||
update_error (Optional[str]): The error message, if any, during the update process.
|
||||
update_value (Optional[str]): The value to be updated, if different from the current value.
|
||||
update_open (Optional[bool]): A flag indicating whether the update section of the card
|
||||
@@ -131,6 +133,9 @@ def ConfigCard(
|
||||
update_value = value
|
||||
if not update_open:
|
||||
update_open = False
|
||||
if deprecated:
|
||||
if isinstance(deprecated, bool):
|
||||
deprecated = "Deprecated"
|
||||
return Card(
|
||||
Details(
|
||||
Summary(
|
||||
@@ -151,13 +156,21 @@ def ConfigCard(
|
||||
Grid(
|
||||
P(description),
|
||||
P(config_type),
|
||||
),
|
||||
)
|
||||
if not deprecated
|
||||
else None,
|
||||
Grid(
|
||||
P(deprecated),
|
||||
P("DEPRECATED!"),
|
||||
)
|
||||
if deprecated
|
||||
else None,
|
||||
# Default
|
||||
Grid(
|
||||
DivRAligned(P("default")),
|
||||
P(default),
|
||||
)
|
||||
if read_only == "rw"
|
||||
if read_only == "rw" and not deprecated
|
||||
else None,
|
||||
# Set value
|
||||
Grid(
|
||||
@@ -172,7 +185,7 @@ def ConfigCard(
|
||||
),
|
||||
),
|
||||
)
|
||||
if read_only == "rw"
|
||||
if read_only == "rw" and not deprecated
|
||||
else None,
|
||||
# Last error
|
||||
Grid(
|
||||
|
||||
@@ -2,6 +2,7 @@ import json
|
||||
from typing import Any, Dict, List, Optional, Sequence, TypeVar, Union
|
||||
|
||||
import requests
|
||||
from loguru import logger
|
||||
from monsterui.franken import (
|
||||
H3,
|
||||
H4,
|
||||
@@ -22,13 +23,10 @@ from pydantic.fields import ComputedFieldInfo, FieldInfo
|
||||
from pydantic_core import PydanticUndefined
|
||||
|
||||
from akkudoktoreos.config.config import ConfigEOS
|
||||
from akkudoktoreos.core.logging import get_logger
|
||||
from akkudoktoreos.core.pydantic import PydanticBaseModel
|
||||
from akkudoktoreos.prediction.pvforecast import PVForecastPlaneSetting
|
||||
from akkudoktoreos.server.dash.components import ConfigCard
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
# Latest configuration update results
|
||||
@@ -166,7 +164,7 @@ def configuration(
|
||||
if found_basic:
|
||||
continue
|
||||
|
||||
config = {}
|
||||
config: dict[str, Optional[Any]] = {}
|
||||
config["name"] = ".".join(values_prefix + parent_types)
|
||||
config["value"] = json.dumps(
|
||||
get_nested_value(values, values_prefix + parent_types, "<unknown>")
|
||||
@@ -175,6 +173,9 @@ def configuration(
|
||||
config["description"] = (
|
||||
subfield_info.description if subfield_info.description else ""
|
||||
)
|
||||
config["deprecated"] = (
|
||||
subfield_info.deprecated if subfield_info.deprecated else None
|
||||
)
|
||||
if isinstance(subfield_info, ComputedFieldInfo):
|
||||
config["read-only"] = "ro"
|
||||
type_description = str(subfield_info.return_type)
|
||||
@@ -319,6 +320,7 @@ def ConfigPlanesCard(
|
||||
config["value"],
|
||||
config["default"],
|
||||
config["description"],
|
||||
config["deprecated"],
|
||||
update_error,
|
||||
update_value,
|
||||
update_open,
|
||||
@@ -457,6 +459,7 @@ def Configuration(
|
||||
if (
|
||||
config["type"]
|
||||
== "Optional[list[akkudoktoreos.prediction.pvforecast.PVForecastPlaneSetting]]"
|
||||
and not config["deprecated"]
|
||||
):
|
||||
# Special configuration for PV planes
|
||||
rows.append(
|
||||
@@ -482,6 +485,7 @@ def Configuration(
|
||||
config["value"],
|
||||
config["default"],
|
||||
config["description"],
|
||||
config["deprecated"],
|
||||
update_error,
|
||||
update_value,
|
||||
update_open,
|
||||
|
||||
@@ -8,7 +8,6 @@ from bokeh.models import ColumnDataSource, LinearAxis, Range1d
|
||||
from bokeh.plotting import figure
|
||||
from monsterui.franken import FT, Grid, P
|
||||
|
||||
from akkudoktoreos.core.logging import get_logger
|
||||
from akkudoktoreos.core.pydantic import PydanticDateTimeDataFrame
|
||||
from akkudoktoreos.server.dash.bokeh import Bokeh
|
||||
|
||||
@@ -17,8 +16,6 @@ FILE_DEMOCONFIG = DIR_DEMODATA.joinpath("democonfig.json")
|
||||
if not FILE_DEMOCONFIG.exists():
|
||||
raise ValueError(f"File does not exist: {FILE_DEMOCONFIG}")
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# bar width for 1 hour bars (time given in millseconds)
|
||||
BAR_WIDTH_1HOUR = 1000 * 60 * 60
|
||||
|
||||
@@ -76,25 +73,37 @@ def DemoElectricityPriceForecast(predictions: pd.DataFrame, config: dict) -> FT:
|
||||
return Bokeh(plot)
|
||||
|
||||
|
||||
def DemoWeatherTempAir(predictions: pd.DataFrame, config: dict) -> FT:
|
||||
def DemoWeatherTempAirHumidity(predictions: pd.DataFrame, config: dict) -> FT:
|
||||
source = ColumnDataSource(predictions)
|
||||
provider = config["weather"]["provider"]
|
||||
|
||||
plot = figure(
|
||||
x_axis_type="datetime",
|
||||
y_range=Range1d(
|
||||
predictions["weather_temp_air"].min() - 1.0, predictions["weather_temp_air"].max() + 1.0
|
||||
),
|
||||
title=f"Air Temperature Prediction ({provider})",
|
||||
title=f"Air Temperature and Humidity Prediction ({provider})",
|
||||
x_axis_label="Datetime",
|
||||
y_axis_label="Temperature [°C]",
|
||||
sizing_mode="stretch_width",
|
||||
height=400,
|
||||
)
|
||||
# Add secondary y-axis for humidity
|
||||
plot.extra_y_ranges["humidity"] = Range1d(start=-5, end=105)
|
||||
y2_axis = LinearAxis(y_range_name="humidity", axis_label="Relative Humidity [%]")
|
||||
y2_axis.axis_label_text_color = "green"
|
||||
plot.add_layout(y2_axis, "left")
|
||||
|
||||
plot.line(
|
||||
"date_time", "weather_temp_air", source=source, legend_label="Air Temperature", color="blue"
|
||||
)
|
||||
|
||||
plot.line(
|
||||
"date_time",
|
||||
"weather_relative_humidity",
|
||||
source=source,
|
||||
legend_label="Relative Humidity [%]",
|
||||
color="green",
|
||||
y_range_name="humidity",
|
||||
)
|
||||
|
||||
return Bokeh(plot)
|
||||
|
||||
|
||||
@@ -150,7 +159,10 @@ def DemoLoad(predictions: pd.DataFrame, config: dict) -> FT:
|
||||
sizing_mode="stretch_width",
|
||||
height=400,
|
||||
)
|
||||
plot.extra_y_ranges["stddev"] = Range1d(0, 1000)
|
||||
# Add secondary y-axis for stddev
|
||||
stddev_min = predictions["load_std"].min()
|
||||
stddev_max = predictions["load_std"].max()
|
||||
plot.extra_y_ranges["stddev"] = Range1d(start=stddev_min - 5, end=stddev_max + 5)
|
||||
y2_axis = LinearAxis(y_range_name="stddev", axis_label="Load Standard Deviation [W]")
|
||||
y2_axis.axis_label_text_color = "green"
|
||||
plot.add_layout(y2_axis, "left")
|
||||
@@ -230,6 +242,7 @@ def Demo(eos_host: str, eos_port: Union[str, int]) -> str:
|
||||
"keys": [
|
||||
"pvforecast_ac_power",
|
||||
"elecprice_marketprice_kwh",
|
||||
"weather_relative_humidity",
|
||||
"weather_temp_air",
|
||||
"weather_ghi",
|
||||
"weather_dni",
|
||||
@@ -260,7 +273,7 @@ def Demo(eos_host: str, eos_port: Union[str, int]) -> str:
|
||||
return Grid(
|
||||
DemoPVForecast(predictions, democonfig),
|
||||
DemoElectricityPriceForecast(predictions, democonfig),
|
||||
DemoWeatherTempAir(predictions, democonfig),
|
||||
DemoWeatherTempAirHumidity(predictions, democonfig),
|
||||
DemoWeatherIrradiance(predictions, democonfig),
|
||||
DemoLoad(predictions, democonfig),
|
||||
cols_max=2,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
import requests
|
||||
from loguru import logger
|
||||
from monsterui.daisy import Loading, LoadingT
|
||||
from monsterui.franken import A, ButtonT, DivFullySpaced, P
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from akkudoktoreos.config.config import get_config
|
||||
from akkudoktoreos.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
config_eos = get_config()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user