Page 1 of 1

combine power to single sensor

Posted: Wednesday 20 September 2023 16:04
by jacobsentertainment
Hi all,

I have this script and it works so far, no errors in the log.

I want to combine the power of three sensors and display that in a dummy sensor (kWh) So far I can see in the log the combined/totalled power.
The sensor 'Totaal Kwh Growatt' is updating but there is no value displayed. If I look in the device tab at this sensor then I do see under data the values changing.

What am I doing wrong here?

Code: Select all

return
{
    on =
    {
        devices =
        {
            499, 503, 507
        }
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'totaal vermogen',
    },

    execute = function(dz)
        local L1 = dz.devices(499).actualWatt
        local L2 = dz.devices(503).actualWatt
        local L3 = dz.devices(507).actualWatt
        local combinedUsage = dz.devices('Totaal Kwh Growatt')
        
        local totpower = ( L1 + L2 + L3 )
    
        combinedUsage.update(totpower, WhActual)
        
        dz.log('# totaal vermogen = '..totpower..'')

    end
}

Re: combine power to single sensor  [Solved]

Posted: Wednesday 20 September 2023 16:23
by waltervl

Code: Select all

combinedUsage.update(totpower, WhActual)
What is WhActual? I think you have mixed up the values.
I think you have to send totpower = 0 but not sure this works for this device.
WhActual = L1+L2+L3
And then use other way around

Code: Select all

combinedUsage.update(WhActual, totpower)
POWER = current power = WhActual
ENERGY = Integer, total cumulative energy in Watt-hours (Wh) = totpower = 0
Also WhActual is a DzVents function name so perhaps better to call it WhActualCombined

Alternatively you can make a dummy Electrical Usage devive
https://www.domoticz.com/wiki/Dummy_for ... lectricity
https://www.domoticz.com/wiki/DzVents:_ ... tric_usage

That needs only 1 parameter
.updateEnergy(energy)
eg

Code: Select all

WhActualCombined = L1+L2+L3
combinedUsage.updateEnergy(WhActualCombined)

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 16:41
by jacobsentertainment
Created a new dummy "Electrical Usage device " and that did the trick. The old one was an "General kWh"
I was probably to much focused on the script and didn't paid attention to the sensor it self.
Thanks Walter, you seem to be al over the forum :-)

And the final script

Code: Select all

return
{
    on =
    {
        devices =
        {
            499, 503, 507
        }
    },

    logging =
    {
        level = domoticz.LOG_ERROR,
        marker = 'totaal vermogen',
    },

    execute = function(dz)
        local L1 = dz.devices(499).actualWatt
        local L2 = dz.devices(503).actualWatt
        local L3 = dz.devices(507).actualWatt
        local combinedUsage = dz.devices(511)
        
        local totpower = ( L1 + L2 + L3 )
    
        combinedUsage.update(0,totpower)
        
        dz.log('# totaal vermogen = '..totpower..'')

    end
}

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 16:53
by ssk17051980
i gone try to copy this :D

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 20:22
by ssk17051980
in my case i have a error.

i create this dummy for the picture.

Error: EventSystem: in KW monitor: [string "return ..."]:13: attempt to index a nil value (global 'domoticz')

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 20:32
by waltervl
You have to create a dummy device type "Usage (Electric)". Not a counter or electric instant and counter.

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 20:43
by jacobsentertainment
And the script is in dzvent, forgot to mention.

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 21:00
by ssk17051980
return
{
on =
{
devices =
{
178, 175, 172
}
},

logging =
{
level = domoticz.LOG_ERROR,
marker = 'totaal vermogen',
},

execute = function(dz)
local L1 = dz.devices(178).actualWatt
local L2 = dz.devices(175).actualWatt
local L3 = dz.devices(172).actualWatt
local combinedUsage = dz.devices(214)

local totpower = ( L1 + L2 + L3 )

combinedUsage.update(0,totpower)

dz.log('# totaal vermogen = '..totpower..'')

end
}


i just replace my idx. i creata that dummy Usage(electric). No error now, but no results .

Re: combine power to single sensor

Posted: Wednesday 20 September 2023 22:13
by waltervl
This script will count the actual Watt that the solar panels are creating at the moment. So if the solar panels are not working the value will be 0

Re: combine power to single sensor

Posted: Thursday 21 September 2023 6:25
by ssk17051980
waltervl wrote: Wednesday 20 September 2023 22:13 This script will count the actual Watt that the solar panels are creating at the moment. So if the solar panels are not working the value will be 0

I want to know my consumption. theoretically shouldn't it also work with the consumed value?

i use shelly 3em to monitor consumption. I have no panels, so the production is zero. I thought it could also work for the total energy consumed
thx

Re: combine power to single sensor

Posted: Thursday 21 September 2023 10:29
by jacobsentertainment
That should also work, what is the log telling you? Go to the log page and typ in the right top corner totaal
(that is stil in you're script)
Also the "last seen time stamp on the new dummy, is this updating?

Re: combine power to single sensor

Posted: Thursday 21 September 2023 11:09
by ssk17051980
the dummy is time out :D
no error in log.
nothing if i write in search box :totaal
if i make any modification in the sript, in the log apear this :
2023-09-21 12:08:50.815 Status: EventSystem: reset all events...
2023-09-21 12:08:50.816 Status: dzVents: Write file: /home/XXXX/domoticz/scripts/dzVents/generated_scripts/Script #1.lua

Re: combine power to single sensor

Posted: Thursday 21 September 2023 20:22
by ssk17051980
any idee what to check ?

Re: combine power to single sensor

Posted: Thursday 21 September 2023 23:50
by waltervl
Seems the script is not triggered. So check the devices you configured in the first lines.