Photovoltaik Visu - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Photovoltaik Visu (/showthread.php?tid=2635) |
Photovoltaik Visu - tirei - 10.05.2020 Hi, I want to visualize my PV system. I use a Schneider IEM3155 for the measurement. Unfortunately I only get the total value in Kwh, but I would like to have the daily value. Here is my script and the error: ---------------- Objektadressen --------------------- -- Hier die Adressen der jeweiligen Objekten einfügen -- Wo der PV-Energiewert gespeichert wird (Objekt) adr_PVEnergie = "1/2/3" -- Wo der PV-Tageswert gespeichert wird (zur Visu) adr_PVTageswert = "1/2/4" -- Wann der Tageswert zurückgesetzt werden soll hour_reset = 23 min_reset = 59 ---- Logik ---- now = os.date(t) if (now.hour == hour_reset and now.min == min_reset) then PVEnergie = grp.getvalue(adr_PVEnergie) storage.set('vortageswert', PVEnergie) grp.write(adr_PVTageswert, 0) else PVEnergie = grp.getvalue(adr_PVEnergie) vortageswert = storage.get('vortageswert') PVTageswert = PVEnergie - vortageswert grp.write(adr_PVTageswert, PVTageswert) end Error: Resident script:30: attempt to perform arithmetic on global 'vortageswert' (a nil value) stack traceback: RE: Photovoltaik Visu - Erwin van der Zwart - 10.05.2020 Hi, The error is probably because the storage is never saved yet due to your condition, then you fetch 'nil' and you cant perform a calculation. Change your code like this Code: else Code: require('luamodbus') Add a trend to your partial registers and you are good to go.. BR, Erwin RE: Photovoltaik Visu - tirei - 10.05.2020 (10.05.2020, 17:02)Erwin van der Zwart Wrote: Hi, |