Page 1 of 1

Count all electrical meters

Posted: Thursday 22 December 2016 8:14
by rudiraz
Hello,

I have 2 Fibaro WallPlugs an one Popp Switsch (all z-wave) with wattmeters.
Now I want to see the combined consumtion of all devices together.

Wattmeter1: 13Watt; Wattmeter2: 30Watt; Wattmeter3: 23Watt --> "Wattmeter total": 66Watt

I need a (virtual) Counter to put all devices in one ("Wattmeter total") together.

How can i do this?

Greetings
rudiraz

Re: Count all electrical meters

Posted: Thursday 22 December 2016 8:35
by emme
try a LUA script as a Time event...

try this:

Code: Select all

totwatt = 0

commandArray = {}

   for devName, devStaus in pairs(otherdevices) do
       if string.sub(devName,1,9) == 'Wattmeter' then
           totwatt = totwatt + tonumber(otherdevices_svalues[devName])
       end
   end
   if totwatt ~= 0 then 
       commandArray['Wattmetertotal'] = tostring(tonumber(otherdevices_svalues[Wattmetertotal]) + totwatt)
   end
did not test it... but it should works

Re: Count all electrical meters

Posted: Thursday 22 December 2016 9:14
by rudiraz
Ok thanks, I have to try it when I am at home.

And this Counter Shows the actual power consumption of all devices called "Wattmeter"?
Can this script be edited to use IDX.?
Then i can choose which Powermeters or Wattmeters (some are called with other names) i want to be listed

Re: Count all electrical meters

Posted: Thursday 22 December 2016 13:05
by geezerrr
cool, i was looking for this one :D
but need some help getting it working,

I created an "All Watt" dummy device and have named all Watt meters like: "device | Power Meter" so i adapted your code a little bit..
to check naming from 11 characters from the end..

but don’t have an output yet.., hope you can help me

Code: Select all

totwatt = 0

commandArray = {}

   for devName, devStaus in pairs(otherdevices) do
        if (devName:sub(-11) =='Power Meter') then
           totwatt=totwatt + tonumber(otherdevices_svalues[devName])
       end
   end
   if totwatt ~= 0 then 
       commandArray['All Watt']=tostring(tonumber(otherdevices_svalues['All Watt']) + totwatt)
   end
   
return commandArray

Re: Count all electrical meters

Posted: Thursday 22 December 2016 17:30
by rudiraz
I copied the lua script, but don't get an update too :|

I made a virtual custom sensor, right?

Re: Count all electrical meters

Posted: Saturday 24 December 2016 10:14
by geezerrr
I'm not a programmer but starting to understand the language. I will play around and when i got it working I post my script. :D

Re: Count all electrical meters

Posted: Sunday 25 December 2016 18:27
by rudiraz
I hope so :D