Hallo zusammen,
Ich habe einen Parse Error im Script (was aber ziemlich sicher schon funktioniert hatte), komme aber irgendwie nicht drauf .
Kann mir ggf. jemand weiterhelfen?
Fehler (bei jedem CRON Aufruf):
javascript.0 2024-08-03 13:18:00.009 error at process.processTimers (node:internal/timers:512:7)
javascript.0 2024-08-03 13:18:00.009 error at listOnTimeout (node:internal/timers:569:17)
javascript.0 2024-08-03 13:18:00.009 error at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7)
javascript.0 2024-08-03 13:18:00.009 error at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28
javascript.0 2024-08-03 13:18:00.009 error at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15)
javascript.0 2024-08-03 13:18:00.008 error at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1769:34)
javascript.0 2024-08-03 13:18:00.008 error at Object.<anonymous> (script.js.Parse.Parse_Sauna_Neu:23:5)
javascript.0 2024-08-03 13:18:00.008 error Error in callback: ReferenceError: Request is not defined
Script:
const url = 'http://192.168.5.113/api';
const idTemp1 = 'javascript.0.Sauna.Sauna';
const idTemp2 = 'javascript.0.Sauna.Sauna_Raum';
createState(idTemp1, 0, {
name: 'Temperatur_Sauna',
desc: 'Temperatur in °C',
type: 'string',
role: 'value',
unit: '°C'
})
createState(idTemp2, 1, {
name: 'Temperatur_Raum',
desc: 'Temperatur in °C',
type: 'string',
role: 'value',
unit: '°C'
})
schedule('*/60 * * * * *', function() { //every minute
Request(url, function(error, response, result) {
let obj = JSON.parse(result);
setState(idTemp1, parseFloat(obj.sensors['0'].value), true);
setState(idTemp2, parseFloat(obj.sensors['1'].value), true);
});
});
JSON von http://192.168.5.113/api :
{
"systemname": "Sauna",
"secure_counter": 236923,
"firmware": "2.3.05-b",
"sensors": [
{
"name": "Sauna Temperature",
"value": 22.3125,
"mean-1": {
"value": 21.80416679,
"count": 60,
"period": 3600
},
"mean-24": {
"value": 19.52482605,
"count": 1440,
"period": 86400
},
"unit": "Celsius",
"time": "Sat Aug 3 13:19:48 2024"
},
{
"name": "Gebäude Temperatur",
"value": 20.375,
"unit": "Celsius",
"time": "Sat Aug 3 13:19:48 2024"
}
]
}