Page 1 of 1

Solivia Gateway to get inverter counters

Posted: Saturday 29 June 2019 12:39
by bjornp
If someone else want to read the Solivia Gateway counters of inverters you can use this.
Edit: do not use os.exit() :? .. It kills Domoticz. Use return instead. Changed code below.

Code: Select all

-- Get Solivia inverter counters
-- Change weburl and inverter device name

return {
    on      =   {   timer   = { "every 5 minutes"}},   
   
    execute = function(dz)            
        local inverter = dz.devices("Solivia invertername")
        weburl='http://<IP_ADRES_OF_GATEWAY>/ID_<ID_OF_INVERTER>'

        local f = assert(io.popen("curl -s " .. weburl, 'r'))
        local s = assert(f:read('*a'))
        f:close()
        
        -- Exit script if inverter is offline or unavailable
        if s:match('Operation failed') then return end

        power=s:match('Actual Power.-<td width="190">(.-)</td>') -- in W
        energy=s:match('Total Energy.-<td width="190">(.-)</td>') -- in kWh
        
        -- Exit script if inverter returns no data available value
        if power == "no data available" or energy == "no data available" then return end
        
        -- print("Power= " .. power .. " W | Energy = " .. energy .. " kWh")
        -- Solivia returns Total energy in kWh but Domoticz expects energy in Wh so multiply by 1000
        inverter.updateElectricity(power,energy*1000)
    end
}

Re: Solivia Gateway to get inverter counters

Posted: Saturday 29 June 2019 13:46
by sincze
Tnx for sharing!