Count all electrical meters

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
rudiraz
Posts: 10
Joined: Thursday 31 December 2015 16:00
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Count all electrical meters

Post 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
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Count all electrical meters

Post 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
The most dangerous phrase in any language is:
"We always done this way"
rudiraz
Posts: 10
Joined: Thursday 31 December 2015 16:00
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: Count all electrical meters

Post 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
geezerrr
Posts: 79
Joined: Tuesday 02 December 2014 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Count all electrical meters

Post 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
rudiraz
Posts: 10
Joined: Thursday 31 December 2015 16:00
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: Count all electrical meters

Post by rudiraz »

I copied the lua script, but don't get an update too :|

I made a virtual custom sensor, right?
geezerrr
Posts: 79
Joined: Tuesday 02 December 2014 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Count all electrical meters

Post 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
rudiraz
Posts: 10
Joined: Thursday 31 December 2015 16:00
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: Count all electrical meters

Post by rudiraz »

I hope so :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest