Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #1421

Merged
merged 12 commits into from
Feb 20, 2024
22 changes: 13 additions & 9 deletions packages/helpermodules/hardware_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
import sys
from typing import Dict

HARDWARE_CONFIGURATION_FILE = "/home/openwb/configuration.json"


def update_hardware_configuration(new_setting: Dict) -> None:
with open("/home/openwb/configuration.json", "r") as f:
with open(HARDWARE_CONFIGURATION_FILE, "r") as f:
data = json.loads(f.read())
with open("/home/openwb/configuration.json", "w") as f:
with open(HARDWARE_CONFIGURATION_FILE, "w") as f:
data.update(new_setting)
f.write(json.dumps(data))


def remove_setting_hardware_configuration(obsolet_setting: str) -> None:
with open("/home/openwb/configuration.json", "r") as f:
with open(HARDWARE_CONFIGURATION_FILE, "r") as f:
data = json.loads(f.read())
with open("/home/openwb/configuration.json", "w") as f:
data.pop(obsolet_setting)
f.write(json.dumps(data))
if obsolet_setting in data:
with open(HARDWARE_CONFIGURATION_FILE, "w") as f:
data.pop(obsolet_setting)
f.write(json.dumps(data))


def get_hardware_configuration_setting(name: str):
with open("/home/openwb/configuration.json", "r") as f:
return json.loads(f.read())[name]
def get_hardware_configuration_setting(name: str, default=None):
with open(HARDWARE_CONFIGURATION_FILE, "r") as f:
configuration = json.loads(f.read())
return configuration.get(name, default)


def get_serial_number() -> str:
Expand Down
2 changes: 1 addition & 1 deletion packages/helpermodules/measurement_logging/process_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def process_entry(entry: dict, next_entry: dict, calculation: CalculationType):
try:
for module in next_entry[type].keys():
if module not in entry[type].keys():
log.warning(f"adding module {module} from next entry")
log.debug(f"adding module {module} from next entry")
entry[type].update({module: {"energy_imported": 0.0, "energy_exported": 0.0}})
except KeyError:
# catch missing "type"
Expand Down
Loading
Loading