using a 3 clamp CM180i for circuit + house

Moderator: leecollings

Post Reply
User avatar
epierre
Posts: 522
Joined: Wednesday 05 March 2014 13:16
Target OS: Linux
Domoticz version:
Location: France
Contact:

using a 3 clamp CM180i for circuit + house

Post by epierre »

Hello,

the CM180i has 3 clamps and can report 3 circuits. But it sums the total in domoticz thus gives incorrect electricity consumption values.

I've made a simple script that is triggered each time the sensors sends up values, I extract clamp 3 which is the whole house and push it in a virtual device.

I need help understanding the second value of the device this way, is that usage value + last usage or something else ?

edit: I've progressed a bit to get the two devices I needed to follow instant usage and money usage ;-)

Code: Select all

function timedifference(s)
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end

function timeCount(numSec)
   local nSeconds = numSec
   if nSeconds == 0 then
      return  "0seconds"
   else
      local sTime = ""
      local nHours = math.floor(nSeconds/3600)
      local nMins = math.floor(nSeconds/60 - (nHours*60))
      if(nHours > 0) then
         sTime = sTime .. nHours
         if(nHours == 1) then
            sTime = sTime .. "hour "
         else
            sTime = sTime .. "hours "
         end
      end
      if(nMins > 0) then
         sTime = sTime .. nMins
              if(nMins == 1) then
            sTime = sTime .. "minute "
         else
            sTime = sTime .. "minutes "
         end
     end
      local nSecs = math.floor(nSeconds - nHours*3600 - nMins *60)
      if(nSecs > 0) then
         sTime = sTime .. nSecs
              if(nSecs == 1) then
            sTime = sTime .. "second"
         else
            sTime = sTime .. "seconds"
         end
      end
      return sTime
   end
end

commandArray = {}
Counter1='CM180i-1 etage/frigo-four/general' -- your physical CM180i multi device
Counter2='ERGY Elec' --your virtual device name
usageid2=384 --your virtual curve only device id
Counter3='ERGY Elec total' --your virtual device name
usageid3=385 --your virtual total device id
voltage=240 --your voltage
if (devicechanged[Counter1]) then
        --456 Watt, 120 Watt, 552 Watt, Total: 5082364.830 Wh
        --T=1.9;0.8;2.6;5082606.047
        l1, l2, l3, tot = otherdevices_svalues[Counter1]:match("([^;]+);([^;]+);([^;]+);([^;]+)")
        c1, c2 = otherdevices_svalues[Counter3]:match("([^;]+);([^;]+)")
        interval = timedifference(otherdevices_lastupdate[Counter1])
        -- convert internal in seconds into hours
        interval = interval / 3600
        wattage=l3*voltage
        t_wattage=c2+wattage*interval
        commandArray[1]={['UpdateDevice']= usageid2 .. "|0|" .. wattage }
        commandArray[2]={['UpdateDevice']= usageid3 .. "|0|" .. wattage .. ";" .. t_wattage}
end

return commandArray

ImperiHome & MyDomoAtHome on top of:
868.42Mhz - Vera Lite - Fibaro SS-101, S-211, K-101, FWP - Fortress SSA2
433Mhz - Cubie Domoticz + RFXtrx + Oregon || Foscam 9821W
2,4Ghz - Cubie MySensors Gateway + COV + TempHumidity + Pressure + WaterMeter
uNGam3R
Posts: 11
Joined: Wednesday 24 December 2014 13:23
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Toulouse, France
Contact:

Re: using a 3 clamp CM180i for circuit + house

Post by uNGam3R »

Hi,

I'm quite confuse regarding your code.
Can you tell more about your intend ?

I own a CM180 and it returns 2 value : power, energy (or the other way around).
Power is an instantaneous measure (in Watt) and Energy is an accumulated count (in kWh).

How does the CM180i works ? Is it returning Amps as your script let believes (you perform a value * voltage somewhere in the middle) ?


For now, what I understood is that your CM180i should return Watt1, Watt2, Watt3, Total_kWh.
Based on that, if you want to extract a single kWh value (because you put the third clamp on main wire supply) you should perform like that:
- Get current Watt from clamp3
- Get last saved kWh stored in an uservariable
- Get last modified time of this uservariable
- Process the time difference between now and the last modification
- Process the kWh calculation in the last period (=(Watt / 1000) * time in hours) --> you have to convert Watt into kW
- Add the delta to your previous accumulated kWh
- Update your counter
- Update the uservariable

Note that I don't advice you to retrieve a value from a dummy energy meter or counter.
I tried and experienced latency leading to offset in data processing.
From my point of view uservariables are way safer to use.

Let me know if it helps you.
Damien.
---------------------------------------
Want more about Domoticz scripts and DiY devices?
Go to ---------- http://mydomotic.blogspot.com
ciottomate
Posts: 5
Joined: Saturday 19 December 2015 10:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: using a 3 clamp CM180i for circuit + house

Post by ciottomate »

Hi,
i have same issue as epierre. (sorry for any error but english is not my native language)
CM180i is basically used for photovoltaic use with OWL account. Works as CM160 but at the end OWL website calculate import / export based on reading from each line.
Unfortunately Domoticz sum by default all 3 channels in CM180i giving an incorrect consumption value as explained before.

However is possible to see all 3 different channels on a dedicated widget but the dedicated widget reading the consumption is incorrect.

in the screenshot :
564 actual consumption
2608 actual photovoltaic production

as you can see the other widget giver sum of CH1 + CH2 (564 + 2608) --> 3173 Watt

Any "muppet proof" solution for me ? As you can understand i'm not familiar with code programming but i would like to see the correct actual consumption ( i don't mind for the import/export photovoltaic).

Thanks in advance for any support !!
Attachments
energy monitor counter
energy monitor counter
Schermata 2015-12-19 alle 11.03.12.png (41.16 KiB) Viewed 2169 times
ciottomate
Posts: 5
Joined: Saturday 19 December 2015 10:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: using a 3 clamp CM180i for circuit + house

Post by ciottomate »

Hello,
i found a "workaround" while waiting a fix.
I used and modified a LUA script made from Eagapov (viewtopic.php?f=4&t=4235) for update two virtual meters with data received from a RFXCOM <--> OWL CM180i to domoticz.

This is my first script ever made in my life, so please apologize any stupid mistake. :oops:

Consumo | Produzione --> is the CM180i (connected to domoticz by RFXCOMM)
horsepower and PVpower --> two virtual meters

Now the instantaneus power is correct (usage and photovoltaic are now separated and not sum) but i would like to understand how to update the counters that (as you can see) seems not working. Probably the "trick" is in the correct usage of commandarray but i'm very beginner.
Any suggestion is welcome.

Code: Select all

--
-- script to copy real OWL data to virtual widgets
--
if devicechanged['Consumo | Produzione'] then 
logging = true
end

local voltage = 235
local offset = 23.5

instantPower, solarpower = string.match(otherdevices_svalues['Consumo | Produzione'], "(%d+%.*%d*);(%d+%.*%d*)")

housePower = voltage * instantPower

-- Adjust OWL phantom voltage during night time
if (timeofday['Nighttime']) then
      PVpower = (voltage * solarpower) - offset else
      PVpower = (voltage * solarpower)
      end

if ( logging ) then
print ( "--------- OWL instantPower: " .. instantPower * voltage)
print ( "--------- OWL solarpower : " .. solarpower * voltage)
end

-- update OWL data to two different virtual widget
commandArray = {}
commandArray[1] = {['UpdateDevice'] = 44 .. "|0|" .. housePower .. ";" .. solarpower }
commandArray[2] = {['UpdateDevice'] = 45 .. "|0|" .. PVpower .. ";" .. solarpower }
return commandArray

Attachments
using new script
using new script
Schermata 2015-12-24 alle 12.08.41.png (50.9 KiB) Viewed 2135 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest