diff --git a/.env b/.env index 2062437..35d9377 100644 --- a/.env +++ b/.env @@ -11,7 +11,7 @@ DOCKER_COMPOSE_DATA_DIR=${HOME}/.local/share/net.akkudoktor.eos # ----------------------------------------------------------------------------- # Image / build # ----------------------------------------------------------------------------- -VERSION=0.2.0.dev70048701 +VERSION=0.2.0.dev81236039 PYTHON_VERSION=3.13.9 # ----------------------------------------------------------------------------- diff --git a/config.yaml b/config.yaml index de5ac70..00aa870 100644 --- a/config.yaml +++ b/config.yaml @@ -6,7 +6,7 @@ # the root directory (no add-on folder as usual). name: "Akkudoktor-EOS" -version: "0.2.0.dev70048701" +version: "0.2.0.dev81236039" slug: "eos" description: "Akkudoktor-EOS add-on" url: "https://github.com/Akkudoktor-EOS/EOS" diff --git a/docs/_generated/configexample.md b/docs/_generated/configexample.md index c0d8a1b..5d68156 100644 --- a/docs/_generated/configexample.md +++ b/docs/_generated/configexample.md @@ -136,7 +136,7 @@ } }, "general": { - "version": "0.2.0.dev81043823", + "version": "0.2.0.dev81236039", "data_folder_path": null, "data_output_subpath": "output", "latitude": 52.52, diff --git a/docs/_generated/configgeneral.md b/docs/_generated/configgeneral.md index 20dfe15..1f65077 100644 --- a/docs/_generated/configgeneral.md +++ b/docs/_generated/configgeneral.md @@ -16,7 +16,7 @@ | latitude | `EOS_GENERAL__LATITUDE` | `Optional[float]` | `rw` | `52.52` | Latitude in decimal degrees between -90 and 90. North is positive (ISO 19115) (°) | | longitude | `EOS_GENERAL__LONGITUDE` | `Optional[float]` | `rw` | `13.405` | Longitude in decimal degrees within -180 to 180 (°) | | timezone | | `Optional[str]` | `ro` | `N/A` | Computed timezone based on latitude and longitude. | -| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev81043823` | Configuration file version. Used to check compatibility. | +| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev81236039` | Configuration file version. Used to check compatibility. | ::: @@ -28,7 +28,7 @@ ```json { "general": { - "version": "0.2.0.dev81043823", + "version": "0.2.0.dev81236039", "data_folder_path": null, "data_output_subpath": "output", "latitude": 52.52, @@ -46,7 +46,7 @@ ```json { "general": { - "version": "0.2.0.dev81043823", + "version": "0.2.0.dev81236039", "data_folder_path": null, "data_output_subpath": "output", "latitude": 52.52, diff --git a/docs/_generated/openapi.md b/docs/_generated/openapi.md index 8a5aa4c..2d8c71d 100644 --- a/docs/_generated/openapi.md +++ b/docs/_generated/openapi.md @@ -1,6 +1,6 @@ # Akkudoktor-EOS -**Version**: `v0.2.0.dev81043823` +**Version**: `v0.2.0.dev81236039` **Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period. diff --git a/openapi.json b/openapi.json index 37b81cf..5818ce4 100644 --- a/openapi.json +++ b/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "Akkudoktor-EOS", "description": "This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.", - "version": "v0.2.0.dev81043823" + "version": "v0.2.0.dev81236039" }, "paths": { "/v1/admin/cache/clear": { @@ -2525,7 +2525,7 @@ "general": { "$ref": "#/components/schemas/GeneralSettings-Output", "default": { - "version": "0.2.0.dev81043823", + "version": "0.2.0.dev81236039", "data_output_subpath": "output", "latitude": 52.52, "longitude": 13.405, @@ -4272,7 +4272,7 @@ "type": "string", "title": "Version", "description": "Configuration file version. Used to check compatibility.", - "default": "0.2.0.dev81043823" + "default": "0.2.0.dev81236039" }, "data_folder_path": { "anyOf": [ @@ -4346,7 +4346,7 @@ "type": "string", "title": "Version", "description": "Configuration file version. Used to check compatibility.", - "default": "0.2.0.dev81043823" + "default": "0.2.0.dev81236039" }, "data_folder_path": { "anyOf": [ diff --git a/src/akkudoktoreos/adapter/homeassistant.py b/src/akkudoktoreos/adapter/homeassistant.py index f33c668..d19720d 100644 --- a/src/akkudoktoreos/adapter/homeassistant.py +++ b/src/akkudoktoreos/adapter/homeassistant.py @@ -455,7 +455,7 @@ class HomeAssistantAdapter(AdapterProvider): measurement_key = entity_id if measurement_key not in measurement_keys: measurement_keys.append(measurement_key) - self.comfig.measurement.load_emr_keys = measurement_keys + self.config.measurement.load_emr_keys = measurement_keys try: state = self.get_entity_state(entity_id) logger.debug(f"Entity {entity_id}: {state}") diff --git a/src/akkudoktoreos/server/rest/starteosdash.py b/src/akkudoktoreos/server/rest/starteosdash.py index 8e3568d..7365412 100644 --- a/src/akkudoktoreos/server/rest/starteosdash.py +++ b/src/akkudoktoreos/server/rest/starteosdash.py @@ -3,6 +3,7 @@ import os import re import sys from pathlib import Path +from typing import Any, MutableMapping from loguru import logger @@ -36,6 +37,58 @@ LOG_PATTERN = re.compile( ) +def patch_loguru_record( + record: MutableMapping[str, Any], + *, + file_name: str, + file_path: str, + line_no: int, + function: str, + logger_name: str = "EOSdash", +) -> None: + """Patch a Loguru log record with subprocess-origin metadata. + + This helper mutates an existing Loguru record in-place to update selected + metadata fields (file, line, function, and logger name) while preserving + Loguru's internal record structure. It must be used with ``logger.patch()`` + and **must not** replace structured fields (such as ``record["file"]``) + with plain dictionaries. + + The function is intended for forwarding log messages originating from + subprocess stdout/stderr streams into Loguru while retaining meaningful + source information (e.g., file path and line number). + + Args: + record: + The Loguru record dictionary provided to ``logger.patch()``. + file_name: + The source file name to assign (e.g. ``"main.py"``). + file_path: + The full source file path to assign + (e.g. ``"/app/server/main.py"``). + line_no: + The source line number associated with the log entry. + function: + The function name associated with the log entry. + logger_name: + The logical logger name to assign to the record. Defaults to + ``"EOSdash"``. + + Notes: + - This function mutates the record in-place and returns ``None``. + - Only attributes of existing structured objects are modified; + no structured Loguru fields are replaced. + - Replacing ``record["file"]`` or similar structured fields with a + dictionary will cause Loguru sinks to fail. + + """ + record["file"].name = file_name + record["file"].path = file_path + record["line"] = line_no + record["function"] = function + record["name"] = logger_name + + async def forward_stream(stream: asyncio.StreamReader, prefix: str = "") -> None: """Continuously read log lines from a subprocess and re-log them via Loguru. @@ -94,16 +147,12 @@ async def forward_stream(stream: asyncio.StreamReader, prefix: str = "") -> None # ---- Patch logger with realistic metadata ---- patched = logger.patch( - lambda r: r.update( - { - "file": { - "name": file_name, - "path": file_path, - }, - "line": line_no, - "function": func_name, - "name": "EOSdash", - } + lambda r: patch_loguru_record( + r, + file_name=file_name, + file_path=file_path, + line_no=line_no, + function=func_name, ) ) @@ -115,16 +164,13 @@ async def forward_stream(stream: asyncio.StreamReader, prefix: str = "") -> None file_path = f"/subprocess/{file_name}" logger.patch( - lambda r: r.update( - { - "file": { - "name": file_name, - "path": file_path, - }, - "line": 1, - "function": "", - "name": "EOSdash", - } + lambda r: patch_loguru_record( + r, + file_name=file_name, + file_path=file_path, + line_no=1, + function="", + logger_name="EOSdash", ) ).info(f"{prefix}{raw}")