Hiermit wird der Datenpunkt erzeugt.
var url = "http://192.168.178.141/api/fetch";
var idTemp = "javascript.0.EzoGateway.Temperatur";
var idPH = "javascript.0.EzoGateway.pH_Wert";
var idRedox = "javascript.0.EzoGateway.Redox_Potential";
// Erzeugen der Objekte in ioBroker
createState(idTemp, 0, {
name: 'Temperatur',
desc: 'Temperatur',
type: 'number',
role: 'value',
unit: '°C'
});
createState(idPH, 0, {
name: 'pH_Wert',
desc: 'pH Wert',
type: 'number',
role: 'value',
unit: ''
});
createState(idRedox, 0, {
name: 'Redox_Potential',
desc: 'Redox potential',
type: 'number',
role: 'value',
unit: 'mV'
});
// schedule('* * * * *', function() { //every minute
schedule("*/2 * * * * *", function() { // every 2s
request(url, function(error, response, result) {
if (result) {
let obj = JSON.parse(result);
setState(idTemp, obj['1'].Value, true);
setState(idPH, obj['2'].Value, true);
setState(idRedox, obj['3'].Value, true);
} else {
var errorMessage = "(" + error + ") ERROR bei Abfrage von: " + url;
log(errorMessage, "warn");
}
});
});```