mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-10-11 11:56:17 +00:00
Nested config, devices registry
* All config now nested. - Use default config from model field default values. If providers should be enabled by default, non-empty default config file could be provided again. - Environment variable support with EOS_ prefix and __ between levels, e.g. EOS_SERVER__EOS_SERVER_PORT=8503 where all values are case insensitive. For more information see: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values - Use devices as registry for configured devices. DeviceBase as base class with for now just initializion support (in the future expand to operations during optimization). - Strip down ConfigEOS to the only configuration instance. Reload from file or reset to defaults is possible. * Fix multi-initialization of derived SingletonMixin classes.
This commit is contained in:
@@ -106,6 +106,11 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence):
|
||||
"measurement_load",
|
||||
]
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
if hasattr(self, "_initialized"):
|
||||
return
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def _interval_count(
|
||||
self, start_datetime: DateTime, end_datetime: DateTime, interval: Duration
|
||||
) -> int:
|
||||
@@ -143,11 +148,16 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence):
|
||||
if topic not in self.topics:
|
||||
return None
|
||||
|
||||
topic_keys = [key for key in self.config.config_keys if key.startswith(topic)]
|
||||
topic_keys = [
|
||||
key for key in self.config.measurement.model_fields.keys() if key.startswith(topic)
|
||||
]
|
||||
key = None
|
||||
if topic == "measurement_load":
|
||||
for config_key in topic_keys:
|
||||
if config_key.endswith("_name") and getattr(self.config, config_key) == name:
|
||||
if (
|
||||
config_key.endswith("_name")
|
||||
and getattr(self.config.measurement, config_key) == name
|
||||
):
|
||||
key = topic + config_key[len(topic) : len(topic) + 1] + "_mr"
|
||||
break
|
||||
|
||||
|
Reference in New Issue
Block a user