Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e387c16
fix(ocppd): log and return charger request errors instead of failing …
Salvialf Oct 16, 2026
787d8de
fix(auth): send badge expiry dates to the charger in UTC OCPP format
Salvialf Oct 16, 2026
cd65d05
fix(ocpp): round charging profile limit to one decimal as required by…
Salvialf Oct 16, 2026
10724dd
fix(ocpp): truncate remote start idTag to the OCPP 20-character limit
Salvialf Oct 16, 2026
8046d22
fix(desktop): cap auth id and charger setting inputs to OCPP lengths
Salvialf Oct 16, 2026
1a13dae
docs: bump pluginVersion & update changelog for 1.0.1
Salvialf Oct 16, 2026
60c62ec
Auto update translation done by jeedom/jeetranslate workflow
Salvialf Oct 16, 2026
f11b4d5
chore(docs): update translations
Salvialf Oct 16, 2026
4d408a0
Merge pull request #17 from jeedom/translations
Salvialf Oct 16, 2026
3a550da
Merge pull request #18 from jeedom/docs-translations
Salvialf Oct 16, 2026
b7bf6ec
refactor(ocpp.js): use let/const instead of var
Salvialf Oct 16, 2026
3cfa36f
feat(ocpp): add start-on-plug-in setting for authorize-all mode
Salvialf Oct 19, 2026
b166ba7
feat(ocpp): start a transaction when a vehicle is plugged in
Salvialf Oct 19, 2026
276ad76
fix(ocpp): declare nullable parameters explicitly for PHP 8.4
Salvialf Oct 19, 2026
2e947b9
docs: document start-on-plug-in mode, clarify id tooltip, bump 1.1.0
Salvialf Oct 19, 2026
c229c84
Auto update translation done by jeedom/jeetranslate workflow
Salvialf Oct 19, 2026
a1a7b7d
chore(docs): update translations
Salvialf Oct 19, 2026
3753d29
Merge pull request #19 from jeedom/translations
Salvialf Oct 19, 2026
d4ec3fd
Merge pull request #20 from jeedom/docs-translations
Salvialf Oct 19, 2026
edb969d
fix(ocpp): send only status and expiry date in authorization responses
Salvialf Oct 30, 2026
6e9b12b
refactor(ocpp): cache auth groups per request
Salvialf Oct 30, 2026
93829ca
fix(ocpp): replace auth group files atomically
Salvialf Oct 30, 2026
e3c82ab
refactor(ocpp): save auth groups server-side and keep new empty groups
Salvialf Oct 30, 2026
c20e5a0
docs(changelog): bump pluginVersion and update changelog for 1.1.1
Salvialf Oct 30, 2026
d1ace92
Auto update translation done by jeedom/jeetranslate workflow
Salvialf Oct 30, 2026
af63fec
chore(docs): update translations
Salvialf Oct 30, 2026
d6a55f4
Merge pull request #23 from jeedom/translations
Salvialf Oct 30, 2026
75e3df1
Merge pull request #24 from jeedom/docs-translations
Salvialf Oct 30, 2026
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
4 changes: 2 additions & 2 deletions core/ajax/ocpp.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
ajax::success($eqLogic->chargerChangeConfiguration(init('key'), init('value')));
}

if (init('action') == 'setAuthGroup') {
ajax::success(ocpp::setAuthGroup(init('groupId'), json_decode(init('authList', array()), true)));
if (init('action') == 'saveAuthGroups') {
ajax::success(ocpp::saveAuthGroups(json_decode(init('groups', array()), true)));
}

if (init('action') == 'getAuthGroup') {
Expand Down
106 changes: 85 additions & 21 deletions core/class/ocpp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

class ocpp extends eqLogic {

private static $_authGroups = array();

public static function standardConfiguration() {
return array(
'AllowOfflineTxForUnknownId' => array(
Expand Down Expand Up @@ -275,6 +277,12 @@ public static function deamon_stop() {
log::add(__CLASS__, 'info', __('Arrêt du démon', __FILE__));
}

public function preSave() {
if ($this->isAutoStartTransactionEnabled() && trim($this->getConfiguration('autoStartIdTag')) === '') {
throw new Exception(__("Veuillez renseigner l'identifiant utilisateur du démarrage au branchement", __FILE__));
}
}

public function postUpdate() {
if ($this->getIsEnable() == 0) {
if ($this->getConfiguration('reachable') == 1) {
Expand All @@ -285,13 +293,26 @@ public function postUpdate() {
}
}

public static function saveAuthGroups(array $_groups) {
$authGroups = (array) config::byKey('authGroups', __CLASS__, array());
foreach ($_groups as $groupId => $group) {
if (isset($group['authList'])) {
self::setAuthGroup($groupId, $group['authList']);
}
$authGroups[$groupId] = $group['name'];
}
config::save('authGroups', $authGroups, __CLASS__);
}

public static function setAuthGroup(string $_groupId, array $_authList = array()) {
$file = __DIR__ . '/../../data/' . $_groupId . '.csv';
if (file_exists($file)) {
unlink($file);
}
if (!empty($_authList)) {
if (($csv = fopen($file, 'w')) !== false) {
if (empty($_authList)) {
if (file_exists($file)) {
unlink($file);
}
} else {
$tmpFile = $file . '.' . config::genKey(8);
if (($csv = fopen($tmpFile, 'w')) !== false) {
log::add(__CLASS__, 'debug', __("Sauvegarde du groupe d'autorisations", __FILE__) . ' : ' . '/plugins/ocpp/data/' . $_groupId . '.csv');
fputcsv($csv, array_map('trim', array_keys($_authList[0])), ';');
foreach ($_authList as $auth) {
Expand All @@ -301,17 +322,21 @@ public static function setAuthGroup(string $_groupId, array $_authList = array()
}
fclose($csv);
}
if (!file_exists($file)) {
if (!file_exists($tmpFile) || !rename($tmpFile, $file)) {
throw new Exception(__('Impossible de sauvegarder la liste des autorisations', __FILE__) . ' : ' . $file);
}
}
unset(self::$_authGroups[$_groupId]);

foreach (self::byTypeAndSearchConfiguration(__CLASS__, ['authGroupId' => $_groupId]) as $eqLogic) {
$eqLogic->updateAuthListCmd();
}
}

public static function getAuthGroup(string $_groupId): array {
if (isset(self::$_authGroups[$_groupId])) {
return self::$_authGroups[$_groupId];
}
$return = array();
$file = __DIR__ . '/../../data/' . $_groupId . '.csv';
if (is_file($file) && ($csv = fopen($file, 'r')) !== false) {
Expand All @@ -324,6 +349,7 @@ public static function getAuthGroup(string $_groupId): array {
}
fclose($csv);
}
self::$_authGroups[$_groupId] = $return;
return $return;
}

Expand All @@ -332,6 +358,7 @@ public static function removeAuthGroup(string $_groupId) {
if (file_exists($file)) {
unlink($file);
}
unset(self::$_authGroups[$_groupId]);

foreach ((self::byTypeAndSearchConfiguration(__CLASS__, ['authGroupId' => $_groupId])) as $eqLogic) {
$eqLogic->setConfiguration('authGroupId', '')->save(true);
Expand All @@ -341,8 +368,8 @@ public static function removeAuthGroup(string $_groupId) {
$authGroups = (array) config::byKey('authGroups', __CLASS__, array());
if (isset($authGroups[$_groupId])) {
unset($authGroups[$_groupId]);
config::save('authGroups', $authGroups, __CLASS__);
}
config::save('authGroups', $authGroups, __CLASS__);
}

public function createCmds() {
Expand Down Expand Up @@ -619,7 +646,7 @@ public function getAuth($_idTag = null): array {
$groupId = $this->getConfiguration('authGroupId');

if ($groupId == 'authorize_all') {
return array('status' => 'Accepted');
return array('status' => 'Accepted', 'expiry_date' => gmdate('Y-m-d\TH:i:s\Z', strtotime('+30 days')));
}

if (!empty($groupId)) {
Expand All @@ -636,13 +663,18 @@ public function getAuth($_idTag = null): array {
}

if (isset($auths[$_idTag]['expiry_date']) && $auths[$_idTag]['expiry_date'] != '') {
if (strtotime($auths[$_idTag]['expiry_date']) <= time()) {
$expiryTime = strtotime($auths[$_idTag]['expiry_date']);
if ($expiryTime <= time()) {
$auths[$_idTag]['status'] = 'Expired';
}
$auths[$_idTag]['expiry_date'] = gmdate('Y-m-d\TH:i:s\Z', $expiryTime);
} else if ($auths[$_idTag]['status'] == 'Accepted') {
$auths[$_idTag]['expiry_date'] = gmdate('Y-m-d\TH:i:s\Z', strtotime('+30 days'));
} else {
unset($auths[$_idTag]['expiry_date']);
}

unset($auths[$_idTag]['name'], $auths[$_idTag]['concurrentTx']);
return $auths[$_idTag];
return array_intersect_key($auths[$_idTag], array_flip(['status', 'expiry_date']));
}
}
return array('status' => 'Invalid');
Expand Down Expand Up @@ -684,7 +716,7 @@ private function setLocalConfiguration(array $_conf) {
return false;
}

public function getLocalConfiguration(string $_key = null, $_default = '') {
public function getLocalConfiguration(?string $_key = null, $_default = '') {
$file = __DIR__ . '/../../data/' . $this->getLogicalId() . '.json';
if (!is_file($file)) {
$conf = $this->chargerGetConfiguration();
Expand Down Expand Up @@ -760,7 +792,7 @@ public function chargerChangeConfiguration(string $_key, string $_value) {
return false;
}

private function chargerGetConfiguration(string $_key = null): array {
private function chargerGetConfiguration(?string $_key = null): array {
$chargerConf = $this->sendToCharger(['method' => 'get_configuration', 'args' => [$_key]]);
if (!empty($chargerConf['unknown_key'])) {
log::add(__CLASS__, 'warning', $this->getHumanName() . '[' . __FUNCTION__ . '] ' . __('Clé(s) de configuration inconnue(s)', __FILE__) . ' : ' . print_r($chargerConf['unknown_key'], true));
Expand All @@ -777,9 +809,33 @@ private function chargerGetConfiguration(string $_key = null): array {
return array();
}

public function chargerStartTransaction(string $_idTag = null, int $_connectorId) {
private function isAutoStartTransactionEnabled(): bool {
return $this->getConfiguration('authGroupId') == 'authorize_all' && $this->getConfiguration('autoStartTransaction') == 1;
}

public function checkAndAutoStartTransaction(int $_connectorId, string $_status, string $_previousStatus) {
if (!$this->isAutoStartTransactionEnabled()) {
return;
}
if ($_connectorId < 1 || $_status != 'Preparing' || !in_array($_previousStatus, ['Available', 'Unavailable', 'Faulted', 'Unreachable', ''])) {
return;
}
$transaction = ocpp_transaction::byCpIdAndConnectorId($this->getLogicalId(), $_connectorId, true);
if (is_object($transaction)) {
log::add(__CLASS__, 'debug', $this->getHumanName() . '[' . $_connectorId . '] ' . __('Transaction déjà en cours, pas de démarrage au branchement', __FILE__) . ' : ' . $transaction->getId());
return;
}
$idTag = $this->getConfiguration('autoStartIdTag');
log::add(__CLASS__, 'info', $this->getHumanName() . '[' . $_connectorId . '] ' . __('Démarrage de la charge au branchement', __FILE__) . ' : ' . $idTag);
$start = $this->chargerStartTransaction($idTag, $_connectorId);
if ($start !== 'Accepted') {
log::add(__CLASS__, 'warning', $this->getHumanName() . '[' . $_connectorId . '] ' . __('Échec du démarrage de la charge au branchement', __FILE__) . ' : ' . print_r($start, true));
}
}

public function chargerStartTransaction(?string $_idTag, int $_connectorId) {
if ($_idTag) {
$start = $this->sendToCharger(['method' => 'start_transaction', 'args' => [$_connectorId, $_idTag]]);
$start = $this->sendToCharger(['method' => 'start_transaction', 'args' => [$_connectorId, mb_substr($_idTag, 0, 20)]]);
if (isset($start['status'])) {
return $start['status'];
}
Expand All @@ -800,7 +856,7 @@ public function chargerStopTransaction(int $_connectorId) {
return false;
}

public function chargerTriggerMessage(string $_message, int $_connectorId = null) {
public function chargerTriggerMessage(string $_message, ?int $_connectorId = null) {
if ($_message == 'BootNotification' || ($this->chargerHasFeature('RemoteTrigger') && in_array($_message, _MESSAGES))) {
$trigger = $this->sendToCharger(['method' => 'trigger_message', 'args' => [$_message, $_connectorId]]);
if (isset($trigger['status'])) {
Expand All @@ -818,7 +874,7 @@ public function chargerSetMaxPower(float $_powerLimit, int $_connectorId = 0): b
return $this->chargerSetChargingProfile($_connectorId, $_powerLimit, 'W');
}

private function chargerClearChargingProfile(int $_id = null, int $_connectorId = null, string $_chargingProfilePurpose = null, int $_stackLevel = null): bool {
private function chargerClearChargingProfile(?int $_id = null, ?int $_connectorId = null, ?string $_chargingProfilePurpose = null, ?int $_stackLevel = null): bool {
if ($this->chargerHasFeature('SmartCharging')) {
$clearProfile = $this->sendToCharger(['method' => 'clear_charging_profile', 'args' => [$_id, $_connectorId, $_chargingProfilePurpose, $_stackLevel]]);
if (isset($clearProfile['status']) && $clearProfile['status'] == 'Accepted') {
Expand All @@ -840,7 +896,7 @@ private function chargerSetChargingProfile(int $_connectorId, float $_limit, str
'chargingRateUnit' => $_chargingRateUnit,
'chargingSchedulePeriod' => [array(
'startPeriod' => 0,
'limit' => $_limit
'limit' => round($_limit, 1)
)]
)
);
Expand Down Expand Up @@ -971,7 +1027,11 @@ private function sendToCharger(array $_data): array {
fclose($sock);
}

log::add(__CLASS__, 'debug', $this->getHumanName() . ' _' . __FUNCTION__ . '(' . $_data['method'] . ') : ' . print_r($return, true));
if (isset($return['status']) && $return['status'] == 'Error') {
log::add(__CLASS__, 'error', $this->getHumanName() . ' ' . __('Échec de la requête à la borne', __FILE__) . ' (' . $_data['method'] . ') : ' . $return['error']);
} else {
log::add(__CLASS__, 'debug', $this->getHumanName() . ' _' . __FUNCTION__ . '(' . $_data['method'] . ') : ' . print_r($return, true));
}
return $return;
}

Expand All @@ -994,9 +1054,13 @@ private function updateAuthListCmd() {
}

private function getAuthList(): string {
if ($this->isAutoStartTransactionEnabled()) {
$autoStartIdTag = $this->getConfiguration('autoStartIdTag');
return $autoStartIdTag . '|' . $autoStartIdTag;
}

$authList = '';
$groupId = $this->getConfiguration('authGroupId');

if ($groupId == 'authorize_all') {
$users = user::all();
foreach ($users as $user) {
Expand Down Expand Up @@ -1043,7 +1107,7 @@ public static function statuses(string $_status) {
return $_status;
}

public static function measurands(string $_measurand = null) {
public static function measurands(?string $_measurand = null) {
$measurands = array(
'Current.Import' => __('Courant consommé', __FILE__),
'Current.Export' => __('Courant injecté', __FILE__),
Expand Down
2 changes: 1 addition & 1 deletion core/class/ocpp_transaction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function start(array $_transactionData): self {
return $transaction;
}

public function stop(string $_date, int $_meterStop, string $_reason = 'Local', array $_transactionData = null) {
public function stop(string $_date, int $_meterStop, string $_reason = 'Local', ?array $_transactionData = null) {
$this->setEnd($_date)
->setOptions('meterStop', $_meterStop)
->setOptions('reason', $_reason);
Expand Down
14 changes: 11 additions & 3 deletions core/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"Durée, en secondes, avant de retransmettre un message en échec relatif à une transaction": "Zeit in Sekunden, bevor eine fehlgeschlagene Nachricht im Zusammenhang mit einer Transaktion erneut gesendet wird",
"Durée, en secondes, avant l'annulation de la transaction si le cable n'est pas inséré dans le véhicule": "Zeit in Sekunden, nach deren Ablauf die Transaktion abgebrochen wird, wenn das Kabel nicht am Fahrzeug angeschlossen ist",
"Déconnecté du système central OCPP": "Vom zentralen OCPP-System getrennt",
"Démarrage de la charge au branchement": "Start des Ladevorgangs beim Anschließen",
"Démarrage du démon": "Daemon starten",
"Démarrer charge": "Ladevorgang starten",
"Désactiver": "Deactivate",
Expand Down Expand Up @@ -102,13 +103,17 @@
"Statut": "Status",
"Température": "Temperatur",
"Tension": "Spannung",
"Transaction déjà en cours, pas de démarrage au branchement": "Transaktion bereits im Gange, kein Start beim Anschließen",
"Utilisateur": "Nutzer",
"Veuillez renseigner l'identifiant utilisateur du démarrage au branchement": "Bitte geben Sie die Benutzer-ID für den Start beim Anschließen ein",
"Vitesse du ventilateur": "Lüftergeschwindigkeit",
"borne": "Anschluss",
"connecteur": "Steckverbinder",
"logiciel": "Software",
"matériel": "Hardware",
"max": "max"
"max": "max",
"Échec de la requête à la borne": "Fehler bei der Anfrage an den Terminal",
"Échec du démarrage de la charge au branchement": "Fehler beim Start des Ladevorgangs beim Anschließen"
},
"plugins\/ocpp\/core\/class\/ocpp_transaction.class.php": {
"Arrêt d'urgence": "Not-Aus",
Expand Down Expand Up @@ -152,7 +157,6 @@
"Expiré": "Abgelaufen",
"Invalide": "Ungültig",
"Les groupes d'autorisations ont été sauvegardés": "Die Berechtigungsgruppen wurden gespeichert",
"Les listes d'autorisations ont été sauvegardées": "Die Berechtigungslisten wurden gespeichert",
"Nom du nouveau groupe d'autorisations ?": "Name der neuen Berechtigungsgruppe?",
"Nouveau nom du groupe d'autorisations ?": "Neuer Name der Berechtigungsgruppe?",
"Supprimer": "Entfernen",
Expand Down Expand Up @@ -238,12 +242,13 @@
"Activer": "Aktivieren",
"Afficher les champs en lecture seule": "Felder als schreibgeschützt anzeigen",
"Aucun": "Nein",
"Aucune autorisation": "Keine Berechtigung",
"Autorisations": "Berechtigungen",
"Catégorie": "Kategorie",
"Commandes": "Befehle",
"Configuration": "Konfiguration",
"Configuration avancée": "Erweiterte Konfiguration",
"Démarrer au branchement": "Inbetriebnahme beim Anschluss",
"Démarrer la charge automatiquement au branchement du véhicule": "Automatischer Start des Ladevorgangs beim Anschließen des Fahrzeugs",
"Enregistrer les paramètres sur la borne": "Einstellungen auf dem Terminal speichern",
"Equipement": "Gerät",
"Equipement non visible": "Nicht sichtbare Ausstattung",
Expand All @@ -253,7 +258,9 @@
"Gestion": "Management",
"Groupe d'autorisations": "Berechtigungsgruppe",
"Identifiant": "ICH WÜRDE",
"Identifiant utilisateur des transactions (20 caractères maximum)": "Benutzername für Transaktionen (maximal 20 Zeichen)",
"Informations": "Information",
"Liste des autorisations pouvant démarrer une charge": "Liste der Berechtigungen, mit denen eine Last gestartet werden kann",
"Mes bornes de recharge": "Meine Ladestationen",
"Modèle": "Modell",
"Nom": "Name",
Expand All @@ -269,6 +276,7 @@
"Sauvegarder": "Zu schützen",
"Supprimer": "Entfernen",
"Tout autoriser": "Alles zulassen",
"Tout refuser": "Alles ablehnen",
"Toute modification erronée est susceptible d'entraîner des dysfonctionnements": "Jede fehlerhafte Änderung kann zu Fehlfunktionen führen",
"Transactions": "Transaktionen",
"Type": "Typ",
Expand Down
Loading
Loading