10.05.2020, 20:04
(10.05.2020, 17:02)Erwin van der Zwart Wrote: 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
Easiest way to do this is to use the partial energy registers from the iEM3155, make sure to disable the "com protection" (enabled by default) on the meter by using the display and create a virtual object and attach a scheduler to it with a event at 00:00 and attach this script to the object and adjust connection details and slave id as neededCode:else
PVEnergie = grp.getvalue(adr_PVEnergie)
vortageswert = storage.get('vortageswert')
if vortageswert == nil then
storage.set('vortageswert', 0)
vortageswert = 0
end
PVTageswert = PVEnergie - vortageswert
The partial energy registers are now receiving a reset command by the command interface every day at 0:00Code:require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(1)
mb:writeregisters(5249, 2020, '')
mb:close()
Add a trend to your partial registers and you are good to go..
BR,
Erwin
thanks for your help, the first script does not work ... the second only works, unfortunately I do not have the Total Active Energy Export modbus register ... and I do not know how to write it into the Modbus register