Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LKuemmel committed Dec 20, 2023
1 parent 0ddf3a0 commit efcbb8f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/control/chargelog/chargelog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import datetime
from enum import Enum
import json
import logging
Expand Down Expand Up @@ -155,8 +155,8 @@ def save_data(chargepoint, charging_ev, immediately: bool = True):
},
"time":
{
"begin": datetime.fromtimestamp(log_data.timestamp_start_charging).strftime("%m/%d/%Y, %H:%M:%S"),
"end": datetime.fromtimestamp(timecheck.create_timestamp()).strftime("%m/%d/%Y, %H:%M:%S"),
"begin": datetime.datetime.fromtimestamp(log_data.timestamp_start_charging).strftime("%m/%d/%Y, %H:%M:%S"),
"end": datetime.datetime.fromtimestamp(timecheck.create_timestamp()).strftime("%m/%d/%Y, %H:%M:%S"),
"time_charged": log_data.time_charged
},
"data":
Expand Down
3 changes: 3 additions & 0 deletions packages/control/optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def et_price_lower_than_limit(self, max_price: float):
return True
else:
return False
except KeyError:
log.exception("Fehler beim strompreisbasierten Laden")
self.et_get_prices()
except Exception:
log.exception("Fehler im Optional-Modul")
return False
Expand Down
8 changes: 4 additions & 4 deletions packages/modules/common/configurable_tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ def __init__(self,
self.__component_updater = component_updater
self.config = config
self.store = store.get_electricity_tariff_value_store()
self.component_info = ComponentInfo(None, self.config.name, ComponentType.ELECTRICITY_TARIFF.value)
self.fault_state = FaultState(ComponentInfo(None, self.config.name, ComponentType.ELECTRICITY_TARIFF.value))

def update(self):
with SingleComponentUpdateContext(self.component_info):
with SingleComponentUpdateContext(self.fault_state):
tariff_state = self.__component_updater()
current_hour = create_unix_timestamp_current_full_hour()
self.store.set(tariff_state)
self.store.update()
for timestamp in tariff_state.prices.keys():
if timestamp < current_hour:
raise FaultState.warning('Die Preisliste startet nicht mit der aktuellen Stunde.')
self.fault_state.warning('Die Preisliste startet nicht mit der aktuellen Stunde.')
if len(tariff_state.prices) < 24:
raise FaultState.no_error(f'Die Preisliste hat nicht 24, sondern {len(tariff_state.prices)} Einträge. '
self.fault_state.no_error(f'Die Preisliste hat nicht 24, sondern {len(tariff_state.prices)} Einträge. '
'Die Strompreise werden vom Anbieter erst um 14:00 für den Folgetag '
'aktualisiert.')
8 changes: 5 additions & 3 deletions packages/modules/common/fault_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def store_error(self) -> None:
topic_prefix = f"openWB/set/{topic}"
else:
topic_prefix = f"openWB/set/{topic}/{self.component_info.id}"
topic_prefix = f"openWB/set/{topic}/{self.component_info.id}"
pub.Pub().pub(f"{topic_prefix}/get/fault_str", self.fault_str)
pub.Pub().pub(f"{topic_prefix}/get/fault_state", self.fault_state.value)
if (self.component_info.parent_hostname and
Expand All @@ -75,8 +74,11 @@ def warning(self, message: str) -> None:
self.fault_str = message
self.fault_state = FaultStateLevel.WARNING

def no_error(self) -> None:
self.fault_str = NO_ERROR
def no_error(self, message: Optional[str] = None) -> None:
if message:
self.fault_str = message
else:
self.fault_str = NO_ERROR
self.fault_state = FaultStateLevel.NO_ERROR

def from_exception(self, exception: Optional[Exception] = None) -> None:
Expand Down

0 comments on commit efcbb8f

Please sign in to comment.