@xwing
Vielen Dank das hat mir geholfen mein Script wieder ans laufen zu bekommen!
Ich melde mich hier allerdings mit einem ähnlichen Problem. Ich bin seit längerem immer mal wieder mit-Leser habe aber dazu noch nichts gefunden.
Das Auslesen der Daten aus dem Senertec Dachs klappt jetzt soweit wieder. Ich habe allerdings noch ein zweites Script mit dem ich den Dachs bisher angefordert habe wenn es hohen Stromverbrauch im Haus gab. Seit dem Update läuft das Script leider nicht mehr zuverlässig und lässt den ganzen Adapter regelmäßig abstürzen und neu starten. Hier mal dazu der Log vom letzten Crash, danach habe ich das anfordern deaktiviert.
2024-06-13 00:51:00.043 - info: javascript.0 (3310163) script.js.common._Stromdurchschnitt_und_BHWK_Anforderung: Stromanforderung Dachs weil morgen viel PV
2024-06-13 00:51:00.114 - info: javascript.0 (3310163) Stopping script script.js.common.Dachs_Anforderung
2024-06-13 00:51:00.208 - info: javascript.0 (3310163) Start JavaScript script.js.common.Dachs_Anforderung (Javascript/js)
2024-06-13 00:51:00.214 - warn: javascript.0 (3310163) script.js.common.Dachs_Anforderung: request package is deprecated - please use httpGet (or a stable lib like axios) instead!
2024-06-13 00:51:00.215 - info: javascript.0 (3310163) script.js.common.Dachs_Anforderung: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
2024-06-13 00:51:00.226 - error: javascript.0 (3310163) script.js.common.Dachs_Anforderung: Error: connect ECONNREFUSED 172.16.240.170:8080
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.16.240.170',
port: 8080
}
2024-06-13 00:51:00.233 - error: javascript.0 (3310163) script.js.common.Dachs_Anforderung: TypeError: Cannot read properties of undefined (reading 'statusCode')
2024-06-13 00:51:00.234 - error: javascript.0 (3310163) at Request._callback (script.js.common.Dachs_Anforderung:8:18)
2024-06-13 00:51:00.235 - error: javascript.0 (3310163) at self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
2024-06-13 00:51:00.235 - error: javascript.0 (3310163) at Request.emit (node:events:517:28)
2024-06-13 00:51:00.235 - error: javascript.0 (3310163) at Request.emit (node:domain:489:12)
2024-06-13 00:51:00.235 - error: javascript.0 (3310163) at Request.onRequestError (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:877:8)
2024-06-13 00:51:00.235 - error: javascript.0 (3310163) at ClientRequest.emit (node:events:529:35)
2024-06-13 00:51:00.236 - error: javascript.0 (3310163) at ClientRequest.emit (node:domain:489:12)
2024-06-13 00:51:00.236 - error: javascript.0 (3310163) at Socket.socketErrorListener (node:_http_client:501:9)
2024-06-13 00:51:00.236 - error: javascript.0 (3310163) at Socket.emit (node:events:517:28)
2024-06-13 00:51:00.237 - error: javascript.0 (3310163) at Socket.emit (node:domain:489:12)
2024-06-13 00:51:00.471 - error: host.raspberrypi-iobroker Caught by controller[0]: TypeError: Cannot read properties of undefined (reading 'statusCode')
2024-06-13 00:51:00.472 - error: host.raspberrypi-iobroker Caught by controller[0]: at Request._callback (script.js.common.Dachs_Anforderung:9:18)
2024-06-13 00:51:00.472 - error: host.raspberrypi-iobroker Caught by controller[0]: at self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
2024-06-13 00:51:00.472 - error: host.raspberrypi-iobroker Caught by controller[0]: at Request.emit (node:events:517:28)
2024-06-13 00:51:00.472 - error: host.raspberrypi-iobroker Caught by controller[0]: at Request.emit (node:domain:489:12)
2024-06-13 00:51:00.472 - error: host.raspberrypi-iobroker Caught by controller[0]: at Request.onRequestError (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:877:8)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker Caught by controller[0]: at ClientRequest.emit (node:events:529:35)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker Caught by controller[0]: at ClientRequest.emit (node:domain:489:12)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker Caught by controller[0]: at Socket.socketErrorListener (node:_http_client:501:9)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker Caught by controller[0]: at Socket.emit (node:events:517:28)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker Caught by controller[0]: at Socket.emit (node:domain:489:12)
2024-06-13 00:51:00.473 - error: host.raspberrypi-iobroker instance system.adapter.javascript.0 terminated with code 1 (JS_CONTROLLER_STOPPED)
2024-06-13 00:51:00.473 - info: host.raspberrypi-iobroker Restart adapter system.adapter.javascript.0 because enabled
2024-06-13 00:51:30.631 - info: host.raspberrypi-iobroker instance system.adapter.javascript.0 started with pid 3426449
2024-06-13 00:51:34.178 - info: javascript.0 (3426449) starting. Version 8.3.1 in /opt/iobroker/node_modules/iobroker.javascript, node: v18.19.1, js-controller: 5.0.19
Das Script sieht aktuell so aus, läuft halt noch auf request:
Bis zum Update klappte das tadellos
var request = require('request');
request.post({
url: 'http://172.16.240.170:8080/setKeys',
form: {'Stromf_Ew.Anforderung_GLT.bAktiv':1,'Stromf_Ew.Anforderung_GLT.bAnzahlModule':1}
}, function(error, response, body) {
if (error) log(error, 'error');
if (response.statusCode==200){
log (body)
}
});
Ich bin leider kein Fachmann was programmieren an geht, sondern kopiere mir Dinge zusammen.
Ich hoffe mir kann hier jemand weiter helfen beim Umbau auf httppost. Bisher bin ich daran gescheitert.