42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
// Durchläuft alle Shelly-Geräte des Shelly-Adapters und setzt den definierten History-Block, damit die Datenpunkte in der History auftauchen. History-Adapter muss installiert sein.
|
|
|
|
addHistoryToState("online");
|
|
stopScript("script.js.Shelly.AddShellyStatesToHistory");
|
|
|
|
function addHistoryToState(state) {
|
|
let hist = { // read out from example
|
|
"history.0": {
|
|
"enabled": true,
|
|
"aliasId": "",
|
|
"debounceTime": 0,
|
|
"blockTime": 0,
|
|
"changesOnly": true,
|
|
"changesRelogInterval": 10,
|
|
"changesMinDelta": 0,
|
|
"ignoreBelowNumber": "",
|
|
"disableSkippedValueLogging": false,
|
|
"retention": "31536000",
|
|
"customRetentionDuration": 365,
|
|
"maxLength": 960,
|
|
"enableDebugLogs": false,
|
|
"debounce": 0
|
|
}
|
|
};
|
|
|
|
$('[id=shelly.0.*.' + state + ']').each(function (id, i) {
|
|
let obj = getObject(id);
|
|
let custom = obj.common.custom;
|
|
let combined = {
|
|
...custom,
|
|
...hist
|
|
};
|
|
|
|
log(id);
|
|
log("custom: " + JSON.stringify(custom));
|
|
log("new: " + JSON.stringify(hist));
|
|
log("combined: " + JSON.stringify(combined));
|
|
obj.common.custom = combined;
|
|
setObject(id, obj); // shows error but is no error
|
|
});
|
|
}
|