Add up more than 2 solarpanel systems in one device

Moderator: leecollings

Post Reply
banne
Posts: 5
Joined: Wednesday 14 July 2021 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Add up more than 2 solarpanel systems in one device

Post by banne »

For people who have more than one solar device and want to add up the total sum... here is the solution

Looks like this:
Schermafbeelding 2021-07-14 om 17.27.18.png
Schermafbeelding 2021-07-14 om 17.27.18.png (22.32 KiB) Viewed 1462 times

Code: Select all

return {
      on = { 
        timer = {
           'every 1 minutes'            
        },
    }, 
    execute = function(domoticz, device, timer)

    local vandaagKwhzon = domoticz.devices('Zonnepanelen carport').counterToday -- Replace everywhere between ' ' with the name of your solar panel device or put -- in front of it if you don't use it
    local vandaagKwhzon2 = domoticz.devices('Zonnepanelen garage').counterToday -- Zonnepanelen S0 device
    local vandaagKwhzon3 = domoticz.devices('Zonnepanelen dak 1').counterToday -- Zonnepanelen S0 device
    local vandaagKwhzon4 = domoticz.devices('Zonnepanelen dak 2').counterToday -- Zonnepanelen S0 device
    local vandaagKwhzon5 = domoticz.devices('Zonnepanelen dak 3').counterToday -- Zonnepanelen S0 device
    local vandaagKwhzon6 = domoticz.devices('Zonnepanelen kantoor').counterToday -- Zonnepanelen S0 device
    
    local zonTotaal = domoticz.devices('Zon opbrengst totaal vandaag') -- Create a customsensor with Kwh as variable and replace the name with your device name
        
        -- Kosten berekenen
        local kwhOpbrengst = tonumber(domoticz.utils.round((vandaagKwhzon + vandaagKwhzon2 + vandaagKwhzon3 + vandaagKwhzon4 + vandaagKwhzon5 + vandaagKwhzon6),2))   
      
        -- Kosten updaten
          zonTotaal.updateCustomSensor(kwhOpbrengst)
    end
} 
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests