Counter Log - Help with kWh calculation

Ricardo Pinto | visiontech pt 4 years ago in bOS Configurator / Tasks updated 4 years ago 24

Hi people,

May I ask a little help about counter log?

I have a power sensor on an electric board. On ETS, I get an Instantaneous Power object (2 bytes), which comes in kW format. Like, if the house is consuming 1200W, I get 1,2 value on ETS, if it's consuming 250W, I get 0,25 value, and so on. I have the correct instant values showing on visualization.

I've tried to create counter logs, to get an approximate daily consumption, etc. The problem is that the values on the counter log don't make any sense.

For example, if the house is consuming constant 250W during 24hour, I should get 6 kWh by the end of the day, but the values don't make sense. On one day, it showed something like 138kWh on one day, which is impossible. I deleted all data now.

Either I'm configuring all wrong the counter log, or there's something I'm missing.

Thanks for any help

Hi Ricardo,

On my installation I have set it a such, but cannot figure out anymore from where I found the formula :

Intensité is in Amp and the Log Energie is in kWh after applying the formula.

I've looked again on the web to retrieve the source of the formula (and see if the result is correct), but as mentioned above, not successful so far. I look further, and should I find it, I'll post the link here. In the meantime, I hope it can help you to go in the right direction



Hi Fabien,

Thanks for the feedback.

Well, in my case I get the data from a ZENNIO KES energy saver meter, which returns the instantaneous power consumption in kW.

If I create a Counter log with the instantaneous power consumption as the input, wasn't it supposed to calculate the daily values, etc? The values don't make any sense, I already quit using the counter log until I find the correct configuration.

I get the instant power consumption in kW and it's correct. I suppose that using that value as an input of the counter log, should calculate how much power I consumed for how long, and present the correct values.

Any extra advise would be great.


Hi Ricardo,

I may be wrong but I think the input only takes a KWH reading, an accumulative value not instantaneous.

Assume your meter has that?


Hi Ricardo,

Looking into the Zennio documentation, it seems you can configure the output to be in kWh and get what you are looking for:

There quite a lot of configuration possibilities, pending what your installation looks like and what you want to achieve. Seems to be a pretty cool device... I hope this will allow you to manage what you are looking for, it is difficult for me to be more precise not having the details of your installation and expectation. 



Hi Fabien and Andy,

I'm not using the KES PLUS, but the KES ENERGY SAVER, which got recently discontinued. Still, it looks a good device. The KES PLUS actually has more options than this, so I don't have most of the options shown.

This older unit, actually let's you get the instantaneous consumption, and I think it calculates the daily weekly and monthly consumption, but I was looking forward to use the counter log from bOS to create my own graphic instead of just getting the values from the KES.

That's why I'm not quite understanding how the counter log works.

I'll try to find any kWh values reading as Andy refered.

Best regards

Hi Ricardo,

Sorry for the mistake, was too quick... However, looking the right documentation (I hope ;-) - ZN1IO-KES), it seems you can send the hourly Energy consumed and even the daily one (refer the active energy section 3.3.1). Would this not be suitable ?



I suppose... but the problem is that the values returned by the last hour consumption etc, don't make any sense, even on ETS.

It's supposed to be 4-Byte signed values, as far as I noted. On ETS, I receive stupid values like 00 00 00 03, and I'm like what?! So in bOS the values show as 0, so I don't know where to go...

Plus, the values returned from KES are pretty weird. For example, I get values for the last hour cost, and day cost etc, but they also don't make sense. Today I'm getting a last hour cost of 0,05€, and a day cost of 0,04€...yeah right.

That's why I decided to use the instantaneous power, which is real time consumption, and use it on a counter log, because the only true correct value I'm getting from the KES is the current power.

Best regards

Knowing you, I'm sure you have the right one, but just to xcheck : are you using DPT 13.013 ?

Yep, DPT 13.013 here...

I really don't know what's wrong...it's pretty weird. Never understood this values, that's why I wanted to just use the current power and leave the calculation to bOS.

Maybe it's a stupid question, but if I know the instant consumption, and use it on a counter log, isn't it suppose the counter log to "see" how much power I used on a certain period of time?

Do I need any extra calculation?

Well.... not sure at all my approach will be correct here, but lets start somewhere.

If you are able to get the power consumption in W per second, the the following calculation could match (if not mistaking):

We can suppose 1 Watt / 1 second = 0.001 KW / 1 second.

So  for 1 Hrs we should have 0.001/3600 = 2,777777777777778e-7 KWh

Now if you multiply this value per the instant consumption value and sum it up you will get the correct value.

ie. 250W * 2,777777777777778e-7 * 3600 seconds * 24 Hrs = 6 kWh.

Now, my only doubt is how to force the counter log to do the calculation every seconds, but maybe you have the answer...

Interesting approach... So basically the calculation is done every second, and I need to care of the sum of the values.

Great, thanks for the tips. Will think about it over the weekend, I'll keep you posted.

Btw, I think the counter log should be doing this...

Just created a fake entry of constant 250 and run it through a calculation before logging... I'll keep you informed of the result.

In parallel I've made a second test logger with my real consumption entry though a similar calculation node....lets see.


Hi Fabien,

I decided to investigate some ways to do the calculation every second, and unfortunately the General timer doesn't have any seconds, just hour and minutes, so I'll have to work with something like Operating time or Timer to count the seconds.

Meanwhile, I've discovered a bug on those functions, 5 seconds missing in each minute.

Until then, there goes the precision calculation. I will try it anyway, to do an approximate calculation, but it will never be 100% accurate until the 5s missing per minute is fixed.

Best regards

Hi Ricardo,

Sorry for my late feedback, but I had an unplanned business trip..

My tests are also not fully satisfactory. The fake device is not recording anything at all, and I don't understand why. I'm sending this 250 value every second on the LAN, the calculation node seems to get it, but the log stay desperately empty....

Regarding the ream consumption node, I get my graph, but seems not to be correct. Either my theoretical solution doesn't work, or there is another issue I don't get with the log.

real and accurate consumption :

Associated energy consumption test log (to be compared to the blue line above) :

Not only the value has a "scaling" issue, but also the shape is wrong. So clearly, it need some more research...


Hi Fabien,

I've also faced problems with my tests, so I have no good results either.

I really don't understand the Counter Log. Wasn't it supposed to accept a simple kW value, log how much it consumed during one hour and spit it out?

Even the Analog Log looks like it gets the values better than the Counter Log. When I created a Counter Log to log the kW values, I also created an Analog Log with the same input, and even tough the Analog Log is not for this purpose, it actually looks better logging values.

So bOS team, please help us out here.

I have a kW value coming from KNX in real time (not kWh), I just want to use bOS to log the consumption. And so far, none of the options worked. The KNX module software sucks, so I just want to take my realtime kW value and calculate the consumption on bOS.

The Counter Log register values every hour, so if I give a kW value as an input, wasn't it suppose to log how much I consumed every hour? Do I need anything eles?

HELP please.

Best regards

Can only add the same request here .... after all these unsuccessful test, help wanted bOS team !

Best regards


I'm also interested in this, actually surprised the counter log does't work with kW and gives back kWh, seems a basic function to me in bOS.

Also as info, the formula to calculate Wh from Amps in the beginning of this thread is wrong, you need to take in account for the power factor (cos φ). Without it you are calculating VA (Volt-Amps), the energie company can't read this value with the standard power meters. Take it as free electricity.


V * Cos φ * A = W

Example: 230 * 0.8 * 2 = 368W

Without cos φ: 230 * 2 = 460VA

If you have a three phase + neutral installation you need to add Square root of 3, √(3) = 1.73

V * √(3) * Cos φ * A = W

Example: 230 * 1.73 * 0.8 * 2 = 636.64

Hello everybody,

I see, that there is a bit of confusion about counter log and energy consumption.

First let me explain how Counter Log works...

Input value of the Counter log should always be consumption (e.g. electrical energy - kWh, gas, water - m3) and not power! 

When we first link the input value to Counter log, it remembers the value. Let's say that when we link our electrical energy meter to counter log it's current value is 100 kWh and counter logs starting value will be 100. However this value is not saved in database, because counter log stores only difference in values in interval of 1 hour so it will actually start with 0. 

Let say that in next hour our energy meter value will be 110 kWh, that means that consumption in that hour was 10 kWh and Counter log will save value 10 in the database. Then after another hour the energy meter value would be 115 kWh and counter log will add 5 to previous database entry and the new entry would be 15 and so on...

Example with power:

Lets say that we have a device that is measuring only active power P (W) and we would like to calculate energy consumption (kWh). 

In this case we first need to calculate energy consumption (kWh) from Power (W) and we can use Calculation task for that.

The formula for energy is E = cos Fi * P * t (let's say cos Fi = 1)

Basically energy is calculated as integration of power:

E(kWh) = Int(P)dt * 1/3600 / 1000

  1. Set Calculus to: Integral.
  2. set Constant Factor to: 1/3600 (Ws -> Wh)  / 1000 (Wh -> kWh) = 2,7778e-7.
  3. Add new operation and select Power as input value in W.
  4. Now you can use Value output in tasks (Counter Log) or make a Double user interface control for it. A Run Function control linked to the Reset function can be used to enable resetting of the counter value.

More examples can be found here:




Thanks Matias, for the extensive explanation, we were trying to find solutions, and honestly we were a bit confused about how the counter log works.

As for step 4, resetting the counter value, what's the use for? Is there any advantage in resetting the counter?

Best regards

No problem, I understand, we will try to improve counter log as well as manuals and tutorials to make it more easier for you...

About reset counter we can take the following analogy:

In car you have counter for overall millage (cannot be reset by the user) and trip millage (can be reset by user). You can do the same in bOS create two counter logs with same input value and do similar things...


Thanks a lot for the feedback and explanations, lots clearer now !

Your right, this deserves a bit more in the manuals and tutorials to avoid further misunderstanding.

Best regards,

Now I think I'm getting results :-D

Will watch the values during the weekend.

Thanks everybody for the tips



Just a quick update:

It looks like it's working pretty well 😁

I took the kWh consumption, added the kWh price and the daily fixed power price, and it looks good so far.

Best regards