Skip to content

Commit

Permalink
chore: release v0.3.4
Browse files Browse the repository at this point in the history
- added config parameter for reconnect delay
  • Loading branch information
TA2k committed Dec 8, 2024
1 parent 6d9c2be commit e648a33
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 138 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Unter commands das commando auf klappen und den button neben start drücken wenn
Remote sind vorgefertige Remote Befehle

## Changelog
### 0.3.4 (2024-12-08)

- added config parameter for reconnect delay

### 0.3.2 (2024-12-06)

Expand Down
261 changes: 141 additions & 120 deletions admin/index_m.html
Original file line number Diff line number Diff line change
@@ -1,133 +1,154 @@
<html>
<head>
<!-- Load ioBroker scripts and styles-->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" />
<head>
<!-- Load ioBroker scripts and styles-->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" />

<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>

<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>

<!-- Load our own files -->
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="words.js"></script>
<!-- Load our own files -->
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="words.js"></script>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$(".value").each(function () {
var $key = $(this);
var id = $key.attr("id");
if ($key.attr("type") === "checkbox") {
// do not call onChange direct, because onChange could expect some arguments
$key.prop("checked", settings[id]).on("change", () => onChange());
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on("change", () => onChange())
.on("keyup", () => onChange());
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}
<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$(".value").each(function () {
var $key = $(this);
var id = $key.attr("id");
if ($key.attr("type") === "checkbox") {
// do not call onChange direct, because onChange could expect some arguments
$key.prop("checked", settings[id]).on("change", () => onChange());
} else {
// do not call onChange direct, because onChange could expect some arguments
$key
.val(settings[id])
.on("change", () => onChange())
.on("keyup", () => onChange());
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}

// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$(".value").each(function () {
var $this = $(this);
if ($this.attr("type") === "checkbox") {
obj[$this.attr("id")] = $this.prop("checked");
} else {
obj[$this.attr("id")] = $this.val();
}
});
callback(obj);
}
</script>
</head>
// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$(".value").each(function () {
var $this = $(this);
if ($this.attr("type") === "checkbox") {
obj[$this.attr("id")] = $this.prop("checked");
} else {
obj[$this.attr("id")] = $this.val();
}
});
callback(obj);
}
</script>
</head>

<body>
<div class="m adapter-container">
<div class="row">
<div class="col s12 m4 l2">
<img src="mercedesme.png" class="logo" />
</div>
</div>
<body>
<div class="m adapter-container">
<div class="row">
<div class="col s12 m4 l2">
<img src="mercedesme.png" class="logo" />
</div>
</div>

<div class="row">
<div class="input-field col col s3">
<input class="value" id="mail" type="text" />
<label for="mail" class="translate">mercedes me mail</label>
</div>
</div>
<div class="row">
<div class="input-field col col s3">
<input class="value" id="loginCode" type="text" />
<label for="loginCode" class="translate">NACH DEM ERSTEN START HIER E-MAIL SICHERHEITSCODE EINGEBEN</label>
</div>
</div>

<div class="row">
<div class="input-field col col s3">
<input class="value" id="mail" type="text" />
<label for="mail" class="translate">mercedes me mail</label>
</div>
</div>
<div class="row">
<div class="input-field col col s3">
<input class="value" id="loginCode" type="text" />
<label for="loginCode" class="translate">NACH DEM ERSTEN START HIER E-MAIL SICHERHEITSCODE EINGEBEN</label>
</div>
</div>
<div class="row">
<div class="input-field col col s3">
<input class="value" id="pin" type="number" />
<label for="pin" class="translate">App Pin to open car</label>
</div>
</div>
<div class="row">
<div class="col s2">
<input class="value" id="resetAccess" type="checkbox" />
<label class="translate" for="resetAccess">Logout</label>
</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="tank" type="text" />
<label for="tank" class="translate"
>Tankvolumen für Tankhistorie (Komma getrennt für mehrere Fahrzeuge)</label
>
</div>
</div>
<div class="row">
<div class="input-field col col s8">
<input class="value" id="capacity" type="text" />
<label for="capacity" class="translate"
>Batterieladekapazität für Stromladehistorie MIT PUNKT TRENNEN nicht KOMMA nutzen. (Komma getrennt für
mehrere Fahrzeuge)</label
>
</div>
<div class="input-field col col s4">
<input class="value" id="kwprice" type="text" />
<label for="kwprice" class="translate">kW Preis MIT PUNKT TRENNEN</label>
</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="apiKey" type="text" />
<label for="apiKey" class="translate">Tankerkönig API Key für aktuellen Treibstoffpreis</label>
</div>
<div class="input-field col col s3">
<input class="value" id="gas" type="text" />
<label for="gas" class="translate">Treibstoffart (diesel, e5, e10)</label>
</div>
</div>

<div class="row">
<div class="input-field col col s3">
<input class="value" id="pin" type="number" />
<label for="pin" class="translate">App Pin to open car</label>
</div>
</div>
<div class="row">
<div class="col s2">
<input class="value" id="resetAccess" type="checkbox" />
<label class="translate" for="resetAccess">Logout</label>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="acceptLanguage" type="text" />
<label for="acceptLanguage" class="translate">Accept Language only non German</label>
</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="countryC" type="text" />
<label for="countryC" class="translate">Country Code only non German</label>
</div>
</div>

</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="tank" type="text" />
<label for="tank" class="translate">Tankvolumen für Tankhistorie (Komma getrennt für mehrere Fahrzeuge)</label>
</div>
</div>
<div class="row">
<div class="input-field col col s8">
<input class="value" id="capacity" type="text" />
<label for="capacity" class="translate">Batterieladekapazität für Stromladehistorie MIT PUNKT TRENNEN nicht KOMMA nutzen. (Komma getrennt für mehrere Fahrzeuge)</label>
</div>
<div class="input-field col col s4">
<input class="value" id="kwprice" type="text" />
<label for="kwprice" class="translate">kW Preis MIT PUNKT TRENNEN</label>
</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="apiKey" type="text" />
<label for="apiKey" class="translate">Tankerkönig API Key für aktuellen Treibstoffpreis</label>
</div>
<div class="input-field col col s3">
<input class="value" id="gas" type="text" />
<label for="gas" class="translate">Treibstoffart (diesel, e5, e10)</label>
</div>
</div>
<div class="row">
<div class="input-field col col s3">
<input class="value" id="pin" type="number" />
<label for="pin" class="translate">App Pin to open car</label>
</div>
</div>

<div class="row">
<div class="input-field col col s4">
<input class="value" id="acceptLanguage" type="text" />
<label for="acceptLanguage" class="translate">Accept Language only non German</label>
</div>
</div>
<div class="row">
<div class="input-field col col s4">
<input class="value" id="countryC" type="text" />
<label for="countryC" class="translate">Country Code only non German</label>
</div>
</div>
<div class="row">
<div class="input-field col col s3">
<input class="value" id="reconnectDelay" type="number" />
<label for="reconnectDelay" class="translate"
>Delay between reconnects in seconds. Increase to prevent rate limit</label
>
</div>
</body>
</div>
</div>
</body>
</html>
21 changes: 16 additions & 5 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "mercedesme",
"version": "0.3.3",
"version": "0.3.4",
"news": {
"0.3.4": {
"en": "added config parameter for reconnect delay",
"de": "Konfigurationsparameter hinzugefügt für Reconnect-Verzögerung",
"ru": "добавлен параметр настройки для задержки перезаключения",
"pt": "parâmetro de configuração adicionado para reconectar o atraso",
"nl": "toegevoegde config parameter voor reconnect delay",
"fr": "paramètre de configuration ajouté pour reconnecter le délai",
"it": "parametro di configurazione aggiunto per riconnettere il ritardo",
"es": "parámetro de configuración añadido para el retraso de reconexión",
"pl": "dodany parametr konfiguracyjny dla opóźnienia ponownego połączenia",
"uk": "додано параметр налаштування для затримки відключення",
"zh-cn": "添加重连接延迟的配置参数"
},
"0.3.3": {
"en": "fix for too many request error",
"de": "Fix für zu viele Anfragen Fehler",
Expand Down Expand Up @@ -80,9 +93,6 @@
"pl": "poprawić wysyłanie kodu",
"uk": "поліпшення відправки коду",
"zh-cn": "改进代码发送"
},
"0.1.6": {
"en": "fix login"
}
},
"titleLang": {
Expand Down Expand Up @@ -159,7 +169,8 @@
"disableSocket": false,
"isAdapter": false,
"ciam": "",
"resetAccess": false
"resetAccess": false,
"reconnectDelay": 60
},
"objects": [],
"instanceObjects": [
Expand Down
13 changes: 3 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ class Mercedesme extends utils.Adapter {
setTimeout(() => {
this.connectWS();
}, 2000);
}, 1 * 60 * 1000); //1min
}, this.config.reconnectDelay * 1000);
});
this.ws.on("close", (data) => {
this.log.debug(data);
Expand All @@ -1552,17 +1552,10 @@ class Mercedesme extends utils.Adapter {
// let parsed = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
// const foo =Client.ClientMessage.deserializeBinary(parsed).toObject()
this.log.silly("WS Message Length: " + data.length);
if (this.wsHeartbeatTimeout) {
clearTimeout(this.wsHeartbeatTimeout);
if (this.reconnectInterval) {
clearInterval(this.reconnectInterval);
}
this.wsHeartbeatTimeout = setTimeout(() => {
this.log.info("Lost WebSocket connection. Reconnect WebSocket");
this.ws.close();
setTimeout(() => {
this.connectWS();
}, 2000);
}, 1 * 60 * 1000); //1min

try {
const message = VehicleEvents.PushMessage.deserializeBinary(data).toObject();
if (message.debugmessage) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
"test:unit": "mocha test/unit --exit",
"release": "release-script --all"
},
"version": "0.3.3"
"version": "0.3.4"
}

0 comments on commit e648a33

Please sign in to comment.