I do this, but I am running openLuup on a RPI 3 so not sure if what I have will be much help, I have this could running a as a service on the RPI
[code]#!/usr/bin/lua5.1
newsol = 0
usage = 0
newuse =0
local socket = require"socket"
local http=require’socket.http’
local group = “224.192.32.19”
local port = 22600
local devusagetemplate = “http://ipofopenLuupRPI/data_request?id=variableset&DeviceNum=45&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=%s&Value=%s”
–urn:micasaverde-com:serviceId:EnergyMetering1
local c = assert(socket.udp())
print(assert(c:setoption(“reuseport”, true)))
print(assert(c:setsockname(“*”, port)))
function valfromchan(src,ch)
search=string.format(“”,ch)
startpos = string.find(src,search)+29
search=string.sub(dgram,startpos,startpos+12)
endpos=string.find(search,‘<’)
search= string.sub(search,1,endpos-1)
– print(tonumber(search))
return (search)
end
print(assert(c:setoption(“ip-add-membership”, {multiaddr = group, interface = “*”})))
while 1 do
dgram = c:receivefrom()
fline=os.date()…‘–> ‘…(string.sub(dgram,1,30))
if string.sub(dgram,2,9) == “electric” then
– extract using units
newuse = valfromchan(dgram,‘0’)
url=string.format(devusagetemplate,‘Usage’,newuse)
retcode = http.request(url)
if retcode == nil then retcode = ‘NotOk’ end
fline=fline…’ > Usage ‘… tostring(newuse)…’ ‘…retcode
else
– extract generating units
if string.sub(dgram,2,6) == “solar” then
startpos=string.find(dgram,‘generating units=’)+21
generate=string.sub(dgram,startpos,startpos+20)
endpos=string.find(generate,’<’)-1
newsol=string.sub(generate,1,endpos)
url=string.format(devusagetemplate,‘Solar’,newsol)
retcode = http.request(url)
if retcode == nil then retcode = ‘NotOk’ end
fline=fline…’ > Solar ‘…tostring(newsol)…’ ‘…retcode
– extract exporting units
startpos=string.find(dgram,‘exporting units=’)+20
export=string.sub(dgram,startpos,startpos+20)
endpos=string.find(export,’<‘)-1
newexp=string.sub(export,1,endpos)
url=string.format(devusagetemplate,‘Export’,newexp)
retcode = http.request(url)
if retcode == nil then retcode = ‘NotOk’ end
fline=fline…’ > Export ‘…tostring(newexp)…’ '…retcode
–calculate import
newsol=tonumber(newsol)
newuse=tonumber(newuse)
import = newuse - newsol
if import<0 then import=0 end
url=string.format(devusagetemplate,'Import',import)
retcode = http.request(url)
if retcode == nil then retcode = 'NotOk' end
fline=fline..' > Import '..tostring(import)..' '..retcode
end
end
print(fline)
end[/code]
It catches the multicast, parses and inserts the data into a dummy device (based on energy calculator) with 4 created variables which are stored in datayours and displayed using Grafana