iobroker Version 7.0.6
installiert auf einem raspberry Pi 4 Model B
Admin Adapter 7.6.17
javascript Adapter 8.9.2
influxdb Adapter 4.0.2
auf dem RasPi läuft neben iobroker auch
- mqtt-broker mosquito
- influxdb2.x
- grafana
Hallo,
ich habe ein Script von haus:automation (Beitrag InfluxDB 2.x - Dashboard für eine PV-Anlage) übernommen und, hoffentlich richtig) an meine Verhältnisse angepasst. Das script mit der Bezeichnung "Sct-Elektro-NetzPower" soll Daten in ein bucket iobrokershort schreiben. Es sieht bei mir nach meinen Anpassungen wie folgt aus:
// Shelly Pro 3EM63 Daten einzelner Phase bei Veränderungen in die influxdb schreiben
// bucket, token und Organisation werden aus den Einstellungen der Instanz in iobroker ausgelesen
// Durch dieses Script haben die Daten einen identischen Zeitstempel
// v0.3;
const influxDbInstance = 'influxdb.0';
const token = 'Kopie des Wertes aus den Instanzeinstellungen zur influxdb.0';
const measurement = 'elektro-power';
const loggingTemplate = {
'0_userdata.0.Elektro.DpShellyStromZaehlerL1Power': 'NetzL1Power',
'0_userdata.0.Elektro.DpShellyStromZaehlerL2Power': 'NetzL2Power',
'0_userdata.0.Elektro.DpShellyStromZaehlerL3Power': 'NetzL3Power',
};
const loggingObj = {};
async function start() {
const influxDbInstanceConfig = await getObjectAsync(`system.adapter.${influxDbInstance}`);
const protocol = influxDbInstanceConfig.native.protocol;
const host = influxDbInstanceConfig.native.host;
const port = influxDbInstanceConfig.native.port;
const org = influxDbInstanceConfig.native.organization;
const bucket = influxDbInstanceConfig.native.dbname;
console.log(`Starting "${measurement}" logging to ${protocol}://${host}:${port} into bucket "${bucket}" by org ${org}`);
// Init loggingObj with current values
for (let [objId, key] of Object.entries(loggingTemplate)) {
const state = await getStateAsync(objId);
if (state && !isNaN(state.val)) {
loggingObj[key] = state.val;
} else {
loggingObj[key] = 0;
}
}
on({ id: Object.keys(loggingTemplate), change: 'ne' }, async (obj) => {
// Update value in loggingObj
const key = loggingTemplate[obj.id];
loggingObj[key] = obj.state.val;
// Save Data
const data = `${measurement} ${Object.keys(loggingObj)
.filter(key => !isNaN(loggingObj[key]))
.map((key) => `${key}=${loggingObj[key]}`)
.join(',')}`;
if (data) {
// console.log(`Saving "${data}" to InfluxDB @ ${protocol}://${host}:${port}/`);
httpPostAsync(`${protocol}://${host}:${port}/api/v2/write?bucket=${bucket}&org=${org}`, data, {
headers: {
'Content-Type': 'text/plain',
'Authorization': `Token ${token}`
}
}).catch(err => console.error(err));
}
});
}
start();
Unter Protokolle erhalte ich im iobroker folgende Fehlermeldungen. Der Zeitstempel der einzelnen Fehlermeldungen unterscheidet sich nur in den dreistelligen Zahlen, die ich hier beispielhaft dem Text vorangestellt habe.
-
:154 script.js.Elektro.Sct-Elektro-NetzPower: httpPost(url=http://172.16.0.6:8086/api/v2/write?bucket=iobrokershort&org=schwedsmart, error=timeout of 2000ms exceeded)
-
:158 script.js.Elektro.Sct-Elektro-NetzPower: Error: timeout of 2000ms exceeded at Object.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:87:43) at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1325:38 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:545:9) at processTimers (node:internal/timers:519:7)
-
:161 script.js.Elektro.Sct-Elektro-NetzPower: httpPost(url=http://172.16.0.6:8086/api/v2/write?bucket=iobrokershort&org=schwedsmart, error=timeout of 2000ms exceeded)
-
:162 script.js.Elektro.Sct-Elektro-NetzPower: Error: timeout of 2000ms exceeded at Object.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:87:43) at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1325:38
-
:169 script.js.Elektro.Sct-Elektro-NetzPower: httpPost(url=http://172.16.0.6:8086/api/v2/write?bucket=iobrokershort&org=schwedsmart, error=timeout of 2000ms exceeded)
-
:170 script.js.Elektro.Sct-Elektro-NetzPower: Error: timeout of 2000ms exceeded at Object.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:87:43) at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1325:38 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:545:9) at processTimers (node:internal/timers:519:7)
Die Daten kommen in influxdb an.
Wie kann ich die Fehlermeldung beheben?
Ich hatte vermutet, dass irgendwas an der Kommunikation zwischen iobroker und influxdb schief läuft. Trotz ausgiebiger Recherche ist es mir nicht gelungen, von anderer Stelle etwas in die influxdb zu schreiben. Was muss ich machen, um
händisch oder über blockly einen Testdatensatz in die influxdb zu schreiben?
Vielen Dank für eure Hilfe.
Schorsch