NEWS
json Object wird unter Objekte nicht richtig angezeigt
-
Servus,
ich speichere tagesdaten im ioBroker als json ab, die werden aber unter Objekte als undefined angezeigt. Kann ich das irgendwie ändern? Lesbar im Script wären die Daten aber. ```var arr = ArrayBuffer;
var h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.0.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.0.total'/total/).val,
pvSolcast : 0.0
};
arr[0] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.1.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.1.total'/total/).val,
pvSolcast : 0.0
};
arr[1] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.2.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.2.total'/total/).val,
pvSolcast : 0.0
};
arr[2] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.3.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.3.total'/total/).val,
pvSolcast : 0.0
};
arr[3] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.4.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.4.total'/total/).val,
pvSolcast : 0.0
};
arr[4] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.5.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.5.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.05:00:00'/Geschätzte Energie/).val
};
arr[5] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.6.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.6.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.06:00:00'/Geschätzte Energie/).val
};
arr[6] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.7.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.7.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.07:00:00'/Geschätzte Energie/).val
};
arr[7] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.8.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.8.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.08:00:00'/Geschätzte Energie/).val
};
arr[8] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.9.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.9.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.09:00:00'/Geschätzte Energie/).val
};
arr[9] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.10.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.10.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.10:00:00'/Geschätzte Energie/).val
};
arr[10] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.11.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.11.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.11:00:00'/Geschätzte Energie/).val
};
arr[11] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.12.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.12.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.12:00:00'/Geschätzte Energie/).val
};
arr[12] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.13.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.13.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.13:00:00'/Geschätzte Energie/).val
};
arr[13] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.14.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.14.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.14:00:00'/Geschätzte Energie/).val
};
arr[14] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.15.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.15.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.15:00:00'/Geschätzte Energie/).val
};
arr[15] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.16.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.16.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.16:00:00'/Geschätzte Energie/).val
};
arr[16] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.17.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.17.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.17:00:00'/Geschätzte Energie/).val
};
arr[17] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.18.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.18.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.18:00:00'/Geschätzte Energie/).val
};
arr[18] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.19.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.19.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.19:00:00'/Geschätzte Energie/).val
};
arr[19] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.20.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.20.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.20:00:00'/Geschätzte Energie/).val
};
arr[20] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.21.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.21.total'/total/).val,
pvSolcast : getState('pvforecast.0.summary.energy.hoursToday.21:00:00'/Geschätzte Energie/).val
};
arr[21] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.22.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.22.total'/total/).val,
pvSolcast :0.0
};
arr[22] = h;h = {
level: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.23.level'/level/).val,
price: getState('tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday.23.total'/total/).val,
pvSolcast :0.0
};
arr[23] = h;setState('0_userdata.0.Strompreise'/Strompreise/, arr, true);
console.log(getState('0_userdata.0.Strompreise'/level/).val)Schon mal vielen dank
-
@jok3r sagte in json Object wird unter Objekte nicht richtig angezeigt:
setState('0_userdata.0.Strompreise'/Strompreise/, arr, true);
//var arr = ArrayBuffer;??? let arr = []; setState('0_userdata.0.Strompreise'/*Strompreise*/, JSON.stringify(arr), true);
Und bevor du ein CodeTag einfügen willst immer erst ein Zeile frei lassen, sonst kann man es nicht vernünftig lesen, wie jetzt.
Bitte korrigieren. -
würde ich so lösen:
const l_tibberlink = "tibberlink.0.Homes.cf930f37-ceea-4c0c-a941-b395fb865fc3.PricesToday."; const l_pvforecast = "pvforecast.0.summary.energy.hoursToday."; const l_Strompreise = "0_userdata.0.Strompreise"; let arr = {}; for (let i = 0; i < 24; i++) { arr[i] = { level: getState(l_tibberlink + i + ".level").val, price: getState(l_tibberlink + i + ".total").val, pvSolcast: (i < 5 || i > 21) ? 0 : getState(l_pvforecast + (i < 10 ? ("0" + i) : i) + ":00:00").val }; } setState(l_Strompreise, JSON.stringify(arr), true); log(JSON.parse(getState(l_Strompreise).val)[18]); //z.b. für Stunde 18