This one is in Lua , not perfect (as I am struggeling with the trigger as well )but working.
My problem is that the updates from the solar are much less then the power meter , hence you get weird values now and then.
I still need to work on report after the solars are not generating energy anymore.
Perhaps it helps you getting started ?
Code: Select all
--
-- Domoticz passes information to scripts through a number of global tables
--
-- device changed contains state and svalues for the device that changed.
-- devicechanged['yourdevicename'] = state
-- devicechanged['svalues'] = svalues string
--
commandArray = {}
--powersensor = "Power"
--if (devicechanged[powersensor]) then
-- print( " ####Power debug: "..devicechanged[powersensor])
-- commandArray['Variable:LUX']=tostring(devicechanged[luxsensor])
-- var1, var2,var3,var4,var5,var6 = string.match(otherdevices_svalues['Power'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
-- print( " ####Power debug: "..var6)
-- end
solarsensor = "SolarEdge kWh"
if (devicechanged[solarsensor]) then
--print( " ####Solar debug: "..devicechanged[solarsensor])
Solarvar1, var2 = string.match(otherdevices_svalues[solarsensor], "(%d+%.*%d*);(%d+%.*%d*)")
print( " ####Solar debug: "..Solarvar1)
powersensor = "Power"
-- if (devicechanged[powersensor]) then
--print( " ####Power debug: "..devicechanged[powersensor])
var1, var2,var3,var4,Powervar5,Powervar6 = string.match(otherdevices_svalues['Power'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
print( " ####Power debug: "..Powervar5)
powercount = tonumber(Powervar6)
solarcount = tonumber(Solarvar1)
consume = solarcount - powercount
print( " ####Consume debug: "..consume)
ttidx = otherdevices_idx['PowerConsumtion']
commandArray['UpdateDevice'] = ttidx..'|0|'..consume
end
return commandArray