10.05.2020, 17:02
(This post was last modified: 10.05.2020, 17:46 by Erwin van der Zwart.)
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 needed
The partial energy registers are now receiving a reset command by the command interface every day at 0:00
Add a trend to your partial registers and you are good to go..
BR,
Erwin
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
PVEnergie = grp.getvalue(adr_PVEnergie)
vortageswert = storage.get('vortageswert')
if vortageswert == nil then
storage.set('vortageswert', 0)
vortageswert = 0
end
PVTageswert = PVEnergie - vortageswert
Code:
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