fix: energy charts bidding zone in request (#948)
Some checks are pending
Bump Version / Bump Version Workflow (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run

Ensure that the bidding zone in the request is correctly set to a
string value (not an enum).

This seems to be also an issue with python version < 3.11. Add safeguards
to only use python >= 3.11. Still keep a regression test for the enum
conversion to string.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2026-03-15 13:32:05 +01:00
committed by GitHub
parent f749caa98c
commit 71e5abce88
13 changed files with 162 additions and 111 deletions

View File

@@ -2,6 +2,7 @@
import calendar
import os
import sys
from typing import Any, ClassVar, Iterator, Optional, Union
import numpy as np
@@ -27,6 +28,28 @@ def is_home_assistant_addon() -> bool:
return "HASSIO_TOKEN" in os.environ or "SUPERVISOR_TOKEN" in os.environ
def runtime_environment() -> str:
"""Return a human-readable description of the runtime environment."""
python_version = sys.version.split()[0]
# Home Assistant add-on
if is_home_assistant_addon():
ha_version = os.getenv("HOMEASSISTANT_VERSION", "unknown")
return f"Home Assistant add-on (HA {ha_version}, Python {python_version})"
# Home Assistant Core integration
if "HOMEASSISTANT_CONFIG" in os.environ:
ha_version = os.getenv("HOMEASSISTANT_VERSION", "unknown")
return f"Home Assistant Core (HA {ha_version}, Python {python_version})"
# Docker container
if os.path.exists("/.dockerenv"):
return f"Docker container (Python {python_version})"
# Default
return f"Standalone Python (Python {python_version})"
class SettingsBaseModel(PydanticBaseModel):
"""Base model class for all settings configurations."""