Skip to content
Open
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
18 changes: 17 additions & 1 deletion packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class UpdateConfig:

DATASTORE_VERSION = 107
DATASTORE_VERSION = 108

valid_topic = [
"^openWB/bat/config/bat_control_permitted$",
Expand Down Expand Up @@ -2701,3 +2701,19 @@ def upgrade(topic: str, payload) -> None:
return {topic: provider}
self._loop_all_received_topics(upgrade)
self._append_datastore_version(107)

def upgrade_datastore_108(self) -> None:
def upgrade(topic: str, payload) -> None:
if re.search("openWB/chargepoint/[0-9]+/config", topic) is not None:
config = decode_payload(payload)
if config.get("type") == "openwb_dc_adapter":
if config["configuration"].get("user") is None:
config["configuration"]["user"] = None
if config["configuration"].get("password") is None:
config["configuration"]["password"] = None
if config["configuration"].get("ip_address") is not None:
ip_address = config["configuration"].pop("ip_address")
config["configuration"]["url"] = f'http://{ip_address}/connect.php'
return {topic: config}
self._loop_all_received_topics(upgrade)
self._append_datastore_version(108)
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(self, config: OpenWBDcAdapter) -> None:
raise Exception(
"DC-Laden muss durch den Support freigeschaltet werden. Bitte nehme Kontakt mit dem Support auf.")
self.efficiency = None
if self.config.configuration.user and self.config.configuration.password:
self.__session.auth = (self.config.configuration.user, self.config.configuration.password)

try:
self.__session.post(
f'http://{self.config.configuration.ip_address}/connect.php',
data={'heartbeatenabled': '1'})
self.__session.post(self.config.configuration.url, data={'heartbeatenabled': '1'})
except Exception:
log.exception(
f"Verbindung zum Ladepunkt {self.config.id} konnte nicht hergestellt werden. "
Expand All @@ -62,11 +62,10 @@ def set_current(self, current: float) -> None:
current = 0
with SingleComponentUpdateContext(self.fault_state, update_always=False):
with self.client_error_context:
ip_address = self.config.configuration.ip_address
raw_current = self.subtract_conversion_loss_from_current(current)
raw_power = raw_current * 3 * 230
log.debug(f"DC-Stromstärke: {raw_current}A ≙ {raw_power / 1000}kW")
self.__session.post('http://'+ip_address+'/connect.php', data={'power': raw_power})
self.__session.post(self.config.configuration.url, data={'power': raw_power})

def subtract_conversion_loss_from_current(self, current: float) -> float:
return current * (self.efficiency if self.efficiency else 0.9)
Expand All @@ -77,8 +76,7 @@ def add_conversion_loss_to_current(self, current: float) -> float:
def get_values(self) -> None:
with SingleComponentUpdateContext(self.fault_state):
with self.client_error_context:
ip_address = self.config.configuration.ip_address
json_rsp = self.__session.get('http://'+ip_address+'/connect.php').json()
json_rsp = self.__session.get(self.config.configuration.url).json()

if json_rsp["fault_state"] == 1:
self.fault_state.warning(json_rsp["fault_str"])
Expand Down
8 changes: 6 additions & 2 deletions packages/modules/chargepoints/openwb_dc_adapter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@


class OpenWBDcAdapterConfiguration:
def __init__(self, ip_address: Optional[str] = None):
self.ip_address = ip_address
def __init__(self, url: Optional[str] = None,
user: Optional[str] = None,
password: Optional[str] = None):
self.url = url
self.user = user
self.password = password


class OpenWBDcAdapter(SetupChargepoint[OpenWBDcAdapterConfiguration]):
Expand Down