NEWS
[Gelöst] Probleme mit Script für Tageserträge
-
Hallo zusammen,
warum auch immer funktionieren einige meiner Scripte auf einmal nicht mehr.
Ich habe mit folgendes Script Stück für Stück zusammengebaut. Auf einmal ging dann gar nichts mehr. Auch Teile davon nicht mehr.function berechnen(){ sendTo('sql.0', 'query', 'SELECT (from_unixtime((ts / 1000))) AS Datum, MAX(val) AS Tageswert FROM iobroker.ts_number WHERE (iobroker.ts_number.id = 8) GROUP BY DAY((from_unixtime((ts / 1000)))) ORDER BY Datum desc LIMIT 7', function (result) { if (result.error) { console.error(result.error); } else { console.log(result.result[0].Tageswert); console.log(result.result[1].Tageswert); console.log(result.result[2].Tageswert); console.log(result.result[3].Tageswert); console.log(result.result[4].Tageswert); console.log(result.result[5].Tageswert); console.log(result.result[6].Tageswert); var Energie_Heute = Math.round[(result.result[0].Tageswert)]; var Energie_Gestern = Math.round[(result.result[1].Tageswert)]; var Energie_Differenz_Heute = Math.round[(result.result[0].Tageswert) - (result.result[1].Tageswert)]; var Energie_Differenz_1 = Math.round[(result.result[1].Tageswert) - (result.result[2].Tageswert)]; setState('javascript.0.Energie_Heute', Energie_Heute); setState ('javascript.0.Energie_Gestern', Energie_Gestern) setState("javascript.0.Energie_Differenz_Heute", Energie_Differenz_Heute); setState("javascript.0.Energie_Differenz_1", Energie_Differenz_1); } } ) }; schedule('* * * * *', berechnen);
Als Log-Ausgabe erhalte ich folgendes:
11:47:00.045 info javascript.0 script.js.Tageserträge: sendTo(adapter=sql.0, cmd=query, msg="SELECT (from_unixtime((ts / 1000))) AS Datum, MAX(val) AS Tageswert FROM iobroker.ts_number WHERE (iobroker.ts_number.id = 8) GROUP BY DAY((from_unixtime((ts / 1000)))) ORDER BY Datum desc LIMIT 7") 11:47:00.932 info javascript.0 script.js.Tageserträge: 153292.02 11:47:00.933 info javascript.0 script.js.Tageserträge: 153199.1 11:47:00.933 info javascript.0 script.js.Tageserträge: 153009.97 11:47:00.933 info javascript.0 script.js.Tageserträge: 152820.83 11:47:00.933 info javascript.0 script.js.Tageserträge: 152631.66 11:47:00.933 info javascript.0 script.js.Tageserträge: 152442.51 11:47:00.933 info javascript.0 script.js.Tageserträge: 152253.36 11:47:00.933 warn javascript.0 at Object.cb (script.js.Tageserträge:21:1) 11:47:00.942 info javascript.0 script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Heute, state=undefined) 11:47:00.942 warn javascript.0 at Object.cb (script.js.Tageserträge:22:1) 11:47:00.945 info javascript.0 script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Gestern, state=undefined) 11:47:00.945 warn javascript.0 at Object.cb (script.js.Tageserträge:23:1) 11:47:00.948 info javascript.0 script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Differenz_Heute, state=undefined) 11:47:00.949 warn javascript.0 at Object.cb (script.js.Tageserträge:24:1) 11:47:00.953 info javascript.0 script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Differenz_1, state=undefined)
Meine Datenpunkte sehen so aus:
Woran liegt es, dass die Datenpunkte nicht mehr mit dem Ergebnis beschrieben werden sondern im Log als state undefined steht?
Bin noch ein ziemlicher Anfänger was Iobroker angeht und Javascript ebenfalls.
Es gibt nur eine Javascript Instanz. Andere Scripte funktionieren noch.
-
@ck_coke
Schau mal in der Reiter "Log", in dem es zu den Warnungen meist noch weitere Informationen gibt. -
@paul53 :
javascript.0 2019-09-30 12:02:01.080 info script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Differenz_1, state=undefined) javascript.0 2019-09-30 12:02:01.080 warn at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) javascript.0 2019-09-30 12:02:01.080 warn at Socket.Readable.push (_stream_readable.js:224:10) javascript.0 2019-09-30 12:02:01.080 warn at readableAddChunk (_stream_readable.js:269:11) javascript.0 2019-09-30 12:02:01.079 warn at addChunk (_stream_readable.js:288:12) javascript.0 2019-09-30 12:02:01.079 warn at Socket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.079 warn at Socket.realHandler (/opt/iobroker/node_modules/ws/lib/WebSocket.js:825:20) javascript.0 2019-09-30 12:02:01.079 warn at Receiver.add (/opt/iobroker/node_modules/ws/lib/Receiver.js:103:24) javascript.0 2019-09-30 12:02:01.079 warn at Receiver.expectHandler (/opt/iobroker/node_modules/ws/lib/Receiver.js:499:31) javascript.0 2019-09-30 12:02:01.079 warn at Receiver.finish (/opt/iobroker/node_modules/ws/lib/Receiver.js:541:12) javascript.0 2019-09-30 12:02:01.079 warn at Receiver.flush (/opt/iobroker/node_modules/ws/lib/Receiver.js:347:3) javascript.0 2019-09-30 12:02:01.079 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:508:14 javascript.0 2019-09-30 12:02:01.079 warn at Receiver.applyExtensions (/opt/iobroker/node_modules/ws/lib/Receiver.js:371:5) javascript.0 2019-09-30 12:02:01.079 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:536:18 javascript.0 2019-09-30 12:02:01.079 warn at Receiver.ontext (/opt/iobroker/node_modules/ws/lib/WebSocket.js:841:10) javascript.0 2019-09-30 12:02:01.079 warn at WebSocket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.079 warn at WebSocket.onMessage (/opt/iobroker/node_modules/ws/lib/WebSocket.js:442:14) javascript.0 2019-09-30 12:02:01.079 warn at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) javascript.0 2019-09-30 12:02:01.079 warn at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) javascript.0 2019-09-30 12:02:01.079 warn at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) javascript.0 2019-09-30 12:02:01.079 warn at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.078 warn at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) javascript.0 2019-09-30 12:02:01.078 warn at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) javascript.0 2019-09-30 12:02:01.078 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.078 warn at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.078 warn at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) javascript.0 2019-09-30 12:02:01.078 warn at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) javascript.0 2019-09-30 12:02:01.078 warn at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) javascript.0 2019-09-30 12:02:01.078 warn at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.078 warn at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) javascript.0 2019-09-30 12:02:01.078 warn at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.078 warn at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.078 warn at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) javascript.0 2019-09-30 12:02:01.077 warn at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) javascript.0 2019-09-30 12:02:01.077 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.077 warn at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:52:30) javascript.0 2019-09-30 12:02:01.077 warn at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3667:71) javascript.0 2019-09-30 12:02:01.077 warn at Object.cb (script.js.Tageserträge:24:1) javascript.0 2019-09-30 12:02:01.077 warn at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1258:20) javascript.0 2019-09-30 12:02:01.077 warn Wrong type of javascript.0.Energie_Differenz_1: "undefined". Please fix, while deprecated and will not work in next versions. javascript.0 2019-09-30 12:02:01.077 info script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Differenz_Heute, state=undefined) javascript.0 2019-09-30 12:02:01.077 warn at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) javascript.0 2019-09-30 12:02:01.077 warn at Socket.Readable.push (_stream_readable.js:224:10) javascript.0 2019-09-30 12:02:01.077 warn at readableAddChunk (_stream_readable.js:269:11) javascript.0 2019-09-30 12:02:01.077 warn at addChunk (_stream_readable.js:288:12) javascript.0 2019-09-30 12:02:01.077 warn at Socket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.077 warn at Socket.realHandler (/opt/iobroker/node_modules/ws/lib/WebSocket.js:825:20) javascript.0 2019-09-30 12:02:01.077 warn at Receiver.add (/opt/iobroker/node_modules/ws/lib/Receiver.js:103:24) javascript.0 2019-09-30 12:02:01.077 warn at Receiver.expectHandler (/opt/iobroker/node_modules/ws/lib/Receiver.js:499:31) javascript.0 2019-09-30 12:02:01.077 warn at Receiver.finish (/opt/iobroker/node_modules/ws/lib/Receiver.js:541:12) javascript.0 2019-09-30 12:02:01.077 warn at Receiver.flush (/opt/iobroker/node_modules/ws/lib/Receiver.js:347:3) javascript.0 2019-09-30 12:02:01.077 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:508:14 javascript.0 2019-09-30 12:02:01.076 warn at Receiver.applyExtensions (/opt/iobroker/node_modules/ws/lib/Receiver.js:371:5) javascript.0 2019-09-30 12:02:01.076 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:536:18 javascript.0 2019-09-30 12:02:01.076 warn at Receiver.ontext (/opt/iobroker/node_modules/ws/lib/WebSocket.js:841:10) javascript.0 2019-09-30 12:02:01.076 warn at WebSocket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.076 warn at WebSocket.onMessage (/opt/iobroker/node_modules/ws/lib/WebSocket.js:442:14) javascript.0 2019-09-30 12:02:01.076 warn at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) javascript.0 2019-09-30 12:02:01.076 warn at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) javascript.0 2019-09-30 12:02:01.076 warn at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) javascript.0 2019-09-30 12:02:01.076 warn at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.076 warn at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) javascript.0 2019-09-30 12:02:01.076 warn at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) javascript.0 2019-09-30 12:02:01.076 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.076 warn at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.076 warn at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) javascript.0 2019-09-30 12:02:01.076 warn at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) javascript.0 2019-09-30 12:02:01.076 warn at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) javascript.0 2019-09-30 12:02:01.076 warn at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.076 warn at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) javascript.0 2019-09-30 12:02:01.076 warn at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.076 warn at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.075 warn at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) javascript.0 2019-09-30 12:02:01.075 warn at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) javascript.0 2019-09-30 12:02:01.075 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.075 warn at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:52:30) javascript.0 2019-09-30 12:02:01.075 warn at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3667:71) javascript.0 2019-09-30 12:02:01.075 warn at Object.cb (script.js.Tageserträge:23:1) javascript.0 2019-09-30 12:02:01.075 warn at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1258:20) javascript.0 2019-09-30 12:02:01.075 warn Wrong type of javascript.0.Energie_Differenz_Heute: "undefined". Please fix, while deprecated and will not work in next versions. javascript.0 2019-09-30 12:02:01.075 info script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Gestern, state=undefined) javascript.0 2019-09-30 12:02:01.075 warn at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) javascript.0 2019-09-30 12:02:01.075 warn at Socket.Readable.push (_stream_readable.js:224:10) javascript.0 2019-09-30 12:02:01.075 warn at readableAddChunk (_stream_readable.js:269:11) javascript.0 2019-09-30 12:02:01.075 warn at addChunk (_stream_readable.js:288:12) javascript.0 2019-09-30 12:02:01.075 warn at Socket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.075 warn at Socket.realHandler (/opt/iobroker/node_modules/ws/lib/WebSocket.js:825:20) javascript.0 2019-09-30 12:02:01.075 warn at Receiver.add (/opt/iobroker/node_modules/ws/lib/Receiver.js:103:24) javascript.0 2019-09-30 12:02:01.075 warn at Receiver.expectHandler (/opt/iobroker/node_modules/ws/lib/Receiver.js:499:31) javascript.0 2019-09-30 12:02:01.075 warn at Receiver.finish (/opt/iobroker/node_modules/ws/lib/Receiver.js:541:12) javascript.0 2019-09-30 12:02:01.075 warn at Receiver.flush (/opt/iobroker/node_modules/ws/lib/Receiver.js:347:3) javascript.0 2019-09-30 12:02:01.075 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:508:14 javascript.0 2019-09-30 12:02:01.074 warn at Receiver.applyExtensions (/opt/iobroker/node_modules/ws/lib/Receiver.js:371:5) javascript.0 2019-09-30 12:02:01.074 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:536:18 javascript.0 2019-09-30 12:02:01.074 warn at Receiver.ontext (/opt/iobroker/node_modules/ws/lib/WebSocket.js:841:10) javascript.0 2019-09-30 12:02:01.074 warn at WebSocket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.074 warn at WebSocket.onMessage (/opt/iobroker/node_modules/ws/lib/WebSocket.js:442:14) javascript.0 2019-09-30 12:02:01.074 warn at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) javascript.0 2019-09-30 12:02:01.074 warn at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) javascript.0 2019-09-30 12:02:01.074 warn at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) javascript.0 2019-09-30 12:02:01.074 warn at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.074 warn at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) javascript.0 2019-09-30 12:02:01.074 warn at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) javascript.0 2019-09-30 12:02:01.074 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.074 warn at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.074 warn at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) javascript.0 2019-09-30 12:02:01.074 warn at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) javascript.0 2019-09-30 12:02:01.074 warn at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) javascript.0 2019-09-30 12:02:01.074 warn at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.073 warn at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) javascript.0 2019-09-30 12:02:01.073 warn at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.073 warn at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.073 warn at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) javascript.0 2019-09-30 12:02:01.073 warn at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) javascript.0 2019-09-30 12:02:01.073 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.073 warn at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:52:30) javascript.0 2019-09-30 12:02:01.073 warn at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3667:71) javascript.0 2019-09-30 12:02:01.073 warn at Object.cb (script.js.Tageserträge:22:1) javascript.0 2019-09-30 12:02:01.073 warn at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1258:20) javascript.0 2019-09-30 12:02:01.073 warn Wrong type of javascript.0.Energie_Gestern: "undefined". Please fix, while deprecated and will not work in next versions. javascript.0 2019-09-30 12:02:01.073 info script.js.Tageserträge: setForeignState(id=javascript.0.Energie_Heute, state=undefined) javascript.0 2019-09-30 12:02:01.073 warn at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) javascript.0 2019-09-30 12:02:01.073 warn at Socket.Readable.push (_stream_readable.js:224:10) javascript.0 2019-09-30 12:02:01.073 warn at readableAddChunk (_stream_readable.js:269:11) javascript.0 2019-09-30 12:02:01.073 warn at addChunk (_stream_readable.js:288:12) javascript.0 2019-09-30 12:02:01.073 warn at Socket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.073 warn at Socket.realHandler (/opt/iobroker/node_modules/ws/lib/WebSocket.js:825:20) javascript.0 2019-09-30 12:02:01.072 warn at Receiver.add (/opt/iobroker/node_modules/ws/lib/Receiver.js:103:24) javascript.0 2019-09-30 12:02:01.072 warn at Receiver.expectHandler (/opt/iobroker/node_modules/ws/lib/Receiver.js:499:31) javascript.0 2019-09-30 12:02:01.072 warn at Receiver.finish (/opt/iobroker/node_modules/ws/lib/Receiver.js:541:12) javascript.0 2019-09-30 12:02:01.072 warn at Receiver.flush (/opt/iobroker/node_modules/ws/lib/Receiver.js:347:3) javascript.0 2019-09-30 12:02:01.072 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:508:14 javascript.0 2019-09-30 12:02:01.072 warn at Receiver.applyExtensions (/opt/iobroker/node_modules/ws/lib/Receiver.js:371:5) javascript.0 2019-09-30 12:02:01.072 warn at /opt/iobroker/node_modules/ws/lib/Receiver.js:536:18 javascript.0 2019-09-30 12:02:01.072 warn at Receiver.ontext (/opt/iobroker/node_modules/ws/lib/WebSocket.js:841:10) javascript.0 2019-09-30 12:02:01.072 warn at WebSocket.emit (events.js:198:13) javascript.0 2019-09-30 12:02:01.072 warn at WebSocket.onMessage (/opt/iobroker/node_modules/ws/lib/WebSocket.js:442:14) javascript.0 2019-09-30 12:02:01.072 warn at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) javascript.0 2019-09-30 12:02:01.072 warn at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) javascript.0 2019-09-30 12:02:01.072 warn at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) javascript.0 2019-09-30 12:02:01.072 warn at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.072 warn at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) javascript.0 2019-09-30 12:02:01.072 warn at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) javascript.0 2019-09-30 12:02:01.072 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.072 warn at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.071 warn at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) javascript.0 2019-09-30 12:02:01.071 warn at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) javascript.0 2019-09-30 12:02:01.071 warn at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) javascript.0 2019-09-30 12:02:01.071 warn at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.071 warn at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) javascript.0 2019-09-30 12:02:01.071 warn at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.071 warn at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) javascript.0 2019-09-30 12:02:01.071 warn at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) javascript.0 2019-09-30 12:02:01.071 warn at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) javascript.0 2019-09-30 12:02:01.071 warn at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) javascript.0 2019-09-30 12:02:01.071 warn at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:52:30) javascript.0 2019-09-30 12:02:01.071 warn at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3667:71) javascript.0 2019-09-30 12:02:01.070 warn at Object.cb (script.js.Tageserträge:21:1) javascript.0 2019-09-30 12:02:01.070 warn at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1258:20) javascript.0 2019-09-30 12:02:01.070 warn Wrong type of javascript.0.Energie_Heute: "undefined". Please fix, while deprecated and will not work in next versions. javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 152253.36 javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 152442.51 javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 152631.66 javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 152820.83 javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 153009.97 javascript.0 2019-09-30 12:02:01.070 info script.js.Tageserträge: 153199.1 javascript.0 2019-09-30 12:02:01.069 info script.js.Tageserträge: 153293.98 javascript.0 2019-09-30 12:02:00.044 info script.js.Tageserträge: sendTo(adapter=sql.0, cmd=query, msg="SELECT (from_unixtime((ts / 1000))) AS Datum, MAX(val) AS Tageswert FROM iobroker.ts_number WHERE (iobroker.ts_number.id = 8) GROUP BY DAY ja
Das einzigste was mir persönlich hier auffällt ist dies:
javascript.0 2019-09-30 12:02:01.070 warn Wrong type of javascript.0.Energie_Heute: "undefined". Please fix, while deprecated and will not work in next versions.
-
Ich habe das Script nun vom Aufbau her umgebaut. So funktioniert es jetzt:
schedule('* * * * *', function() { // sendTo('sql.0', 'query', 'SELECT (from_unixtime((ts / 1000))) AS Datum, MAX(val) AS Tageswert FROM iobroker.ts_number WHERE (iobroker.ts_number.id = 8) GROUP BY DAY((from_unixtime((ts / 1000)))) ORDER BY Datum desc LIMIT 7', function (result) { if (result.error) { console.error(result.error); } else { console.log(result.result[0].Tageswert); console.log(result.result[1].Tageswert); console.log(result.result[2].Tageswert); console.log(result.result[3].Tageswert); console.log(result.result[4].Tageswert); console.log(result.result[5].Tageswert); console.log(result.result[6].Tageswert); var Energie_Heute = (result.result[0].Tageswert); var Energie_Gestern = (result.result[1].Tageswert); var Energie_Differenz_Heute = (result.result[0].Tageswert) - (result.result[1].Tageswert); var Energie_Differenz_1 = (result.result[1].Tageswert) - (result.result[2].Tageswert); setState("javascript.0.Zählerstand_Jetzt", Energie_Heute.toFixed(2)); setState ("javascript.0.Zählerstand_Gestern", Energie_Gestern.toFixed(2)); setState("javascript.0.Energie_Differenz_Heute", Energie_Differenz_Heute.toFixed(2)); setState("javascript.0.Energie_Differenz_1", Energie_Differenz_1.toFixed(2)); } }); // });