@machamster [sagte]: Habe ich irgend etwas falsch gemacht?
idJson enthält keine Datenpunkt-ID, sondern eine URL.
EDIT: Eine URL muss man pollen (Intervall):
const url = ''; // URL eintragen!
// Datenpunkte vom Typ "Zahl" unter "0_userdata.0.PV" erstellen!
const idPower = '0_userdata.0.PV.Leistung'; // kW
const idEnergy = '0_userdata.0.PV.Energie'; // kWh
const idAct = '0_userdata.0.PV.aktueller_Monat'; // kWh
const idLast = '0_userdata.0.PV.letzter_Monat'; // kWh
const idMonth = '0_userdata.0.PV.Stand_Monat'; // kWh
var stand = getState(idEnergy).val; // Zählerstand
var energy = 100 * stand; // 10 Wh
setInterval(function() {
httpGet(url, (err, response) => {
if (!err) {
const status = JSON.parse(response.data).ESSRealtimeStatus;
setState(idPower, status.PvPw, true);
}
});
}, 5000); // alle 5 s
on(idPower, function(dp) {
energy += dp.oldState.val * (dp.state.lc - dp.oldState.lc) / 36000;
stand = Math.round(energy) / 100; // Zählerstand kWh
setState(idEnergy, stand, true);
setState(idAct, stand - getState(idMonth).val, true);
});
schedule('55 59 23 28-31 * *', function() {
if(new Date(Date.now() + 10000).getDate() == 1) { // letzter Monatstag
setState(idLast, stand - getState(idMonth).val, true);
setState(idMonth, stand, true);
setState(idAct, 0, true);
}
});
Bitte Code in Code tags posten, damit man daraus kopieren kann.
Verpasse den Datenpunkten noch Einheiten (kW / kWh) und setze sie auf "read only" mit der Rolle "value.power".
Beachte bitte, dass ich um eine Variable stand ergänzt habe, die den berechneten Zählerstand auf zwei Nachkommastellen gerundet enthält.