Skip to content
Merged
3 changes: 3 additions & 0 deletions packages/control/chargepoint/chargepoint_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class Get:
charging_power: Optional[float] = 0
charging_voltage: Optional[float] = 0
connected_vehicle: ConnectedVehicle = field(default_factory=connected_vehicle_factory)
current_branch: Optional[str] = None
current_commit: Optional[str] = None
currents: List[float] = field(default_factory=currents_list_factory)
daily_imported: float = 0
daily_exported: float = 0
Expand All @@ -115,6 +117,7 @@ class Get:
soc_timestamp: Optional[int] = None
state_str: Optional[str] = None
vehicle_id: Optional[str] = None
version: Optional[str] = None
voltages: List[float] = field(default_factory=voltages_list_factory)


Expand Down
16 changes: 16 additions & 0 deletions packages/helpermodules/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ def chargepointShutdown(self, connection_id: str, payload: dict) -> None:
hostname=SubData.cp_data[payload["data"]["chargepoint"]
].chargepoint.chargepoint_module.config.configuration.ip_address)

def secondaryChargepointUpdate(self, payload: dict) -> None:
pub.pub_single("openWB/set/command/primary/todo",
{"command": "systemUpdate", "data": {}},
hostname=SubData.cp_data[payload["data"]["chargepoint"]
].chargepoint.chargepoint_module.config.configuration.ip_address)

def systemReboot(self, connection_id: str, payload: dict) -> None:
pub_user_message(payload, connection_id, "Neustart wird ausgeführt.", MessageType.INFO)
parent_file = Path(__file__).resolve().parents[2]
Expand Down Expand Up @@ -728,6 +734,16 @@ def systemUpdate(self, connection_id: str, payload: dict) -> None:
run_command([
str(parent_file / "runs" / "update_self.sh"),
SubData.system_data["system"].data["current_branch"]])
if not SubData.general_data.data.extern and SubData.system_data["system"].data["secondary_auto_update"]:
for cp in SubData.cp_data.values():
# if chargepoint is external_openwb and not the second CP of duo and version is Release
if (
cp.chargepoint.chargepoint_module.config.type == 'external_openwb' and
cp.chargepoint.chargepoint_module.config.configuration.duo_num == 0 and
cp.chargepoint.data.get.current_branch == "Release"
):
time.sleep(2)
self.secondaryChargepointUpdate({"data": {"chargepoint": f"cp{cp.chargepoint.num}"}})

def systemFetchVersions(self, connection_id: str, payload: dict) -> None:
log.info("Fetch versions requested")
Expand Down
6 changes: 6 additions & 0 deletions packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,10 @@ def process_chargepoint_get_topics(self, msg):
elif ("/get/evse_current" in msg.topic or
"/get/max_evse_current" in msg.topic):
self._validate_value(msg, float, [(0, 0), (6, 32), (600, 3200)])
elif ("/get/version" in msg.topic or
"/get/current_branch" in msg.topic or
"/get/current_commit" in msg.topic):
self._validate_value(msg, str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fehlt in der setdata nicht noch die neue Einstellung "secondary_auto_update"?

elif ("/get/error_timestamp" in msg.topic or
"/get/rfid_timestamp" in msg.topic):
self._validate_value(msg, float)
Expand Down Expand Up @@ -1073,6 +1077,8 @@ def process_system_topic(self, msg: mqtt.MQTTMessage):
self._validate_value(msg, "json")
elif "openWB/set/system/mqtt/valid_partner_ids" == msg.topic:
self._validate_value(msg, str, collection=list)
elif "openWB/set/system/secondary_auto_update" == msg.topic:
self._validate_value(msg, bool)
elif "configurable" in msg.topic:
self._validate_value(msg, None)
elif "device" in msg.topic:
Expand Down
5 changes: 5 additions & 0 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class UpdateConfig:
"^openWB/chargepoint/[0-9]+/control_parameter/timestamp_switch_on_off$",
"^openWB/chargepoint/[0-9]+/get/charge_state$",
"^openWB/chargepoint/[0-9]+/get/currents$",
"^openWB/chargepoint/[0-9]+/get/current_branch$",
"^openWB/chargepoint/[0-9]+/get/current_commit$",
"^openWB/chargepoint/[0-9]+/get/evse_current$",
"^openWB/chargepoint/[0-9]+/get/fault_state$",
"^openWB/chargepoint/[0-9]+/get/fault_str$",
Expand All @@ -120,6 +122,7 @@ class UpdateConfig:
"^openWB/chargepoint/[0-9]+/get/powers$",
"^openWB/chargepoint/[0-9]+/get/power_factors$",
"^openWB/chargepoint/[0-9]+/get/vehicle_id$",
"^openWB/chargepoint/[0-9]+/get/version$",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier fehlt auch der Eintrag für secondary_auto_update.

"^openWB/chargepoint/[0-9]+/get/voltages$",
"^openWB/chargepoint/[0-9]+/get/serial_number$",
"^openWB/chargepoint/[0-9]+/get/soc$",
Expand Down Expand Up @@ -444,6 +447,7 @@ class UpdateConfig:
"^openWB/system/mqtt/bridge/[0-9]+$",
"^openWB/system/mqtt/valid_partner_ids$",
"^openWB/system/release_train$",
"^openWB/system/secondary_auto_update$",
"^openWB/system/time$",
"^openWB/system/update_in_progress$",
"^openWB/system/usage_terms_acknowledged$",
Expand Down Expand Up @@ -540,6 +544,7 @@ class UpdateConfig:
("openWB/system/ip_address", "unknown"),
("openWB/system/mqtt/valid_partner_ids", []),
("openWB/system/release_train", "master"),
("openWB/system/secondary_auto_update", True),
("openWB/system/serial_number", get_serial_number()),
)
invalid_topic = (
Expand Down
8 changes: 7 additions & 1 deletion packages/modules/common/component_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def __init__(self,
soc_timestamp: Optional[int] = None,
evse_current: Optional[float] = None,
vehicle_id: Optional[str] = None,
max_evse_current: Optional[int] = None):
max_evse_current: Optional[int] = None,
current_branch: Optional[str] = None,
current_commit: Optional[str] = None,
version: Optional[str] = None):
self.currents, self.powers, self.voltages = _calculate_powers_and_currents(currents, powers, voltages)
self.frequency = frequency
self.imported = imported
Expand All @@ -200,6 +203,9 @@ def __init__(self,
self.evse_current = evse_current
self.max_evse_current = max_evse_current
self.vehicle_id = vehicle_id
self.current_branch = current_branch
self.current_commit = current_commit
self.version = version


@auto_str
Expand Down
3 changes: 3 additions & 0 deletions packages/modules/common/store/_chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def update(self):
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/evse_current", self.state.evse_current)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/vehicle_id", self.state.vehicle_id)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/max_evse_current", self.state.max_evse_current)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/version", self.state.version)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/current_branch", self.state.current_branch)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/current_commit", self.state.current_commit)


def get_chargepoint_value_store(id: int) -> ValueStore[ChargepointState]:
Expand Down
5 changes: 5 additions & 0 deletions packages/modules/common/store/_chargepoint_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def update(self):
"/get/evse_current", self.state.evse_current, 2)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) +
"/get/max_evse_current", self.state.max_evse_current, 2)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) + "/get/version", self.state.version)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) +
"/get/current_branch", self.state.current_branch)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) +
"/get/current_commit", self.state.current_commit)


def get_internal_chargepoint_value_store(id: int) -> ValueStore[ChargepointState]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from modules.common.fault_state import ComponentInfo, FaultState
from modules.common.store import get_internal_chargepoint_value_store, get_chargepoint_value_store
from modules.internal_chargepoint_handler.clients import ClientHandler
from helpermodules.subdata import SubData

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -54,6 +55,9 @@ def __init__(self, local_charge_point_num: int,
self._client.evse_client.activate_precise_current()
self._precise_current = self._client.evse_client.is_precise_current_active()
self.max_evse_current = self._client.evse_client.get_max_current()
self.version = SubData.system_data["system"].data["version"]
self.current_branch = SubData.system_data["system"].data["current_branch"]
self.current_commit = SubData.system_data["system"].data["current_commit"]

def set_current(self, current: float) -> None:
with SingleComponentUpdateContext(self.fault_state, update_always=False):
Expand Down Expand Up @@ -116,7 +120,10 @@ def store_state(chargepoint_state: ChargepointState) -> None:
rfid=last_tag,
evse_current=self.set_current_evse,
serial_number=serial_number,
max_evse_current=self.max_evse_current
max_evse_current=self.max_evse_current,
version=self.version,
current_branch=self.current_branch,
current_commit=self.current_commit
)
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@pytest.mark.parametrize(
"old_chargepoint_state, published_topics",
[(None, 44),
[(None, 50),
(OLD_CHARGEPOINT_STATE, 2)]

)
Expand Down