Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def set_current(self, current: float) -> None:
hostname=self.config.configuration.ip_address)

def get_values(self) -> None:
with SingleComponentUpdateContext(self.fault_state, update_always=False):
with SingleComponentUpdateContext(self.fault_state):
with self.client_error_context:
ip_address = self.config.configuration.ip_address
num = self.config.id
Expand Down
11 changes: 5 additions & 6 deletions packages/modules/chargepoints/openwb_pro/chargepoint_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ def __init__(self, config: OpenWBPro) -> None:
f"openWB/set/chargepoint/{self.config.id}/get/error_timestamp", CP_ERROR, hide_exception=True)

with SingleComponentUpdateContext(self.fault_state, update_always=False):
with self.client_error_context:
self.__session.post(
'http://' + self.config.configuration.ip_address + '/connect.php',
data={'heartbeatenabled': '1'})
self.__session.post(
'http://' + self.config.configuration.ip_address + '/connect.php',
data={'heartbeatenabled': '1'})

def set_internal_context_handlers(self, internal_cp: InternalChargepoint, parent_hostname: str):
def set_internal_context_handlers(self, hierarchy_id: int, internal_cp: InternalChargepoint, parent_hostname: str):
self.fault_state = FaultState(ComponentInfo(
self.config.id,
"Ladepunkt "+str(self.config.id),
"internal_chargepoint",
parent_id=internal_cp.data.parent_cp,
hierarchy_id=hierarchy_id,
parent_hostname=parent_hostname))
self.client_error_context = ErrorTimerContext(
f"openWB/set/internal_chargepoint/{self.config.id}/get/error_timestamp", CP_ERROR, hide_exception=True)
Expand Down
15 changes: 7 additions & 8 deletions packages/modules/common/fault_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def __init__(self,
name: str,
type: str,
hostname: str = "localhost",
parent_id: Optional[int] = None,
hierarchy_id: Optional[int] = None,
parent_hostname: Optional[str] = None) -> None:
self.id = id
self.name = name
self.type = type
self.hostname = hostname
self.parent_id = parent_id
self.hierarchy_id = hierarchy_id
self.parent_hostname = parent_hostname

@staticmethod
Expand Down Expand Up @@ -57,12 +57,11 @@ def store_error(self) -> None:
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
self.component_info.parent_hostname != self.component_info.hostname):
pub.pub_single(f"openWB/set/{topic}/{self.component_info.parent_id}/get/fault_str",
self.fault_str, hostname=self.component_info.parent_hostname)
pub.pub_single(f"openWB/set/{topic}/{self.component_info.parent_id}/get/fault_state",
self.fault_state.value, hostname=self.component_info.parent_hostname)
if self.component_info.type == "internal_chargepoint":
pub.pub_single(f"openWB/set/chargepoint/{self.component_info.hierarchy_id}/get/fault_str",
self.fault_str)
pub.pub_single(f"openWB/set/chargepoint/{self.component_info.hierarchy_id}/get/fault_state",
self.fault_state.value)
except Exception:
log.exception("Fehler im Modul fault_state")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def __init__(self, local_charge_point_num: int,
hierarchy_id: int) -> None:
self.local_charge_point_num = local_charge_point_num
self.fault_state = FaultState(ComponentInfo(
hierarchy_id,
local_charge_point_num,
"Ladepunkt "+str(local_charge_point_num),
"internal_chargepoint",
parent_id=internal_cp.data.parent_cp,
hierarchy_id=hierarchy_id,
parent_hostname=parent_hostname))
self.store_internal = get_internal_chargepoint_value_store(local_charge_point_num)
self.store = get_chargepoint_value_store(hierarchy_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ def __init__(self,
self.event_stop = event_stop
self.heartbeat = False
self.fault_state_info_cp0 = FaultState(
ComponentInfo(hierarchy_id_cp0, "Interner Ladepunkt 0", "chargepoint", parent_id=parent_cp0,
ComponentInfo(0, "Interner Ladepunkt 0", "internal_chargepoint", hierarchy_id=hierarchy_id_cp0,
parent_hostname=global_data.parent_ip))
fault_state_info_cp1 = FaultState(
ComponentInfo(hierarchy_id_cp1, "Interner Ladepunkt 1", "chargepoint", parent_id=parent_cp1,
ComponentInfo(1, "Interner Ladepunkt 1", "internal_chargepoint", hierarchy_id=hierarchy_id_cp1,
parent_hostname=global_data.parent_ip))
with SingleComponentUpdateContext(self.fault_state_info_cp0, reraise=True):
self.init_gpio()
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/internal_chargepoint_handler/pro_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, local_charge_point_num: int,
self.old_chargepoint_state = None

super().__init__(OpenWBPro(configuration=OpenWBProConfiguration(ip_address="192.168.192.50")))
super().set_internal_context_handlers(internal_cp, parent_hostname)
super().set_internal_context_handlers(hierarchy_id, internal_cp, parent_hostname)

def get_values(self, phase_switch_cp_active: bool, last_tag: str) -> ChargepointState:
def store_state(chargepoint_state: ChargepointState) -> None:
Expand Down