Page 1 of 1

Daily energy usage (KWH)

Posted: Sunday 23 May 2021 20:54
by jonathan12
I All,

I put an ESP8266 (easy esp) in my Car charger (Laadpaal) with a Modbus power meter.
The ESP8266 is connected to the power meter with a RS485 to TTL converter and sends the data to domoticz.

In domoticz I now have Power Voltage, Current, and Total energy usage of the power meter.
I would like to see the daily power usage of the charger with bar graph.

I searched for day, but I can not find a working option.
How can I make this?

Image

Image

Re: Daily energy usage (KWH)

Posted: Monday 24 May 2021 1:09
by waltervl
Then you need another type of virtual device like Electricity (instant and counter) or Counter. See also the wiki page for an overview ( work in progress) https://www.domoticz.com/wiki/Dummy_for ... counter.29

Re: Daily energy usage (KWH)

Posted: Monday 24 May 2021 12:07
by jonathan12
I have tested the Electricity (instant and counter) a few day ago.
Instant was showing 3000Watt, but the counter stays 0. What kind of input does the counter needed?
After waiting a day the counter still stays 0.

Re: Daily energy usage (KWH)

Posted: Monday 24 May 2021 12:29
by waltervl
from https://www.domoticz.com/wiki/Domoticz_ ... counter.29

/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=POWER;ENERGY

IDX = id of your device (This number can be found in the devices tab in the column "IDX")
POWER = current power
ENERGY = cumulative energy in Watt-hours (Wh) This is an incrementing counter.
if you choose as type "Energy read : Computed", this is just a "dummy" counter, not updatable because Domoticz will calculate this internally based on the (previous/current) POWER value

Re: Daily energy usage (KWH)

Posted: Tuesday 25 May 2021 19:22
by jonathan12
Ok, I created a new virtual device (instant and counter).

Easy ESP:
Image

Domoticz: No data:
Image

Domoticz:
Image

In Domotics you see: 0, 3027.10;228.70;13;0.99 Why is the first number a 0?
The RFX counter is receiving the same data from ESP easy, and there I see only: 3.017 kWh, without a zero.

Mmm strange, I see some info, but it is very very little.

Image

Image

Image

Re: Daily energy usage (KWH)

Posted: Tuesday 25 May 2021 19:35
by waltervl
The espeasy configuration for combined devices (W, V, A, cosphi ) is not working in Domoticz. You have to make 1 esp device for each parameter you want to monitor in Domoticz. So in your case make a Espeasy device for watt only. Then it hopefully sends the correct values.

Other option is to use Espeasy rules to send http API calls to Domoticz.
/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=POWER;ENERGY.

Please check the documentation of espeasy. For example https://www.letscontrolit.com/wiki/inde ... SendToHTTP

Edit: and perhaps better https://www.letscontrolit.com/wiki/inde ... th_own_IDX

Re: Daily energy usage (KWH)

Posted: Tuesday 25 May 2021 19:39
by jonathan12
I use multiple devices to sent it to domoticz.

One device for voltage
one for Ampere etc.

I will try the Api calls. Thanks!

Re: Daily energy usage (KWH)

Posted: Tuesday 25 May 2021 20:36
by waltervl
jonathan12 wrote: Tuesday 25 May 2021 19:39 I use multiple devices to sent it to domoticz.

One device for voltage
one for Ampere etc.

According your screenshot of espeasy you have 1 device with multiple parameters, all on 1 idx. That is not possible in Domoticz.

For the rules there is one issue with the syntax that gets scrambled up somehow after &param= but there is a workaround.

Re: Daily energy usage (KWH)

Posted: Friday 28 May 2021 12:15
by jonathan12
Ok, i change it.

Easy ESP:
Image

Script:

on Eastron120M#A do
SendToHTTP x.x.x.x,port,/json.htm?type=command&param=udevice&idx=106&nvalue=0&svalue=[Eastron120M#A] //Sent A to Domoticz
endon

on Eastron120M#V do
SendToHTTP x.x.x.x,port,/json.htm?type=command&param=udevice&idx=107&nvalue=0&svalue=[Eastron120M#V] //Sent V to Domoticz
endon

on Eastron120M#W do
SendToHTTP x.x.x.x,port,/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=[Eastron120M#W] //Sent W to Domoticz
endon

on Eastron120M#Wh_tot do
SendToHTTP x.x.x.x,port,/json.htm?type=command&param=udevice&idx=109&nvalue=0&svalue=[Eastron120M#Wh_tot] //Sent Wh_tot to Domoticz
endon

on Eastron120M#W do
SendToHTTP x.x.x.x,port,/json.htm?type=command&param=udevice&idx=139&nvalue=0&svalue=[Eastron120M#W] //Sent W to Domoticz
endon

Results: Laadpaal dagelijks stays 0.

Image

Why is there always a 0 by Electric instant + counter?

Re: Daily energy usage (KWH)

Posted: Friday 28 May 2021 15:07
by waltervl
What do you get if you update by browser
Http:\\x.x.x.x:port\json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=0,307

Perhaps , . difference so instead of sending 0,307 send 0.307

Re: Daily energy usage (KWH)

Posted: Friday 28 May 2021 15:15
by jonathan12
http://x.x.x/.x:xxxx/json.htm?type=comm ... alue=0,308
Result in Domoticz:
Laadpaal dagelijk: 0, 0,308

http://x.x.x.x:xxxx/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=0.307
Result in Domoticz:
Laadpaal dagelijks: 0, 0.307


http://x.x.x.x:xxxx/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=3000
Result in Domoticz:
Laadpaal dagelijks: 0, 3000

Re: Daily energy usage (KWH)

Posted: Friday 28 May 2021 16:00
by waltervl
And is the device set to computed (through edit button)?
Because it needs 2 svalues POWER (watt) and ENERGY (Wh). If set to computed it will ignore the given ENERGY value and calculate it.
idx=IDX&nvalue=0&svalue=POWER;ENERGY.

What if you send
http://x.x.x.x:xxxx/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=307;0

Re: Daily energy usage (KWH)

Posted: Sunday 30 May 2021 11:30
by jonathan12
I did not know I had to set it to computed.

If I set it to compute the input of easy ESP is not received by domoticz.
If I try:
http://x.x.x.x:xxxx/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=307;0

results:
{
"status" : "OK",
"title" : "Update Device"
}

Domoticz no update, old values:
141 ESP8266 00082141 1 Laadpaal dagelijks General kWh 0, 3000

And if I do:
http://x.x.x.x:xxxx/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=307
Domoticz is still showing the old values and no update.

Re: Daily energy usage (KWH)

Posted: Sunday 30 May 2021 14:10
by waltervl
II get normal readings when setting up a dummy Electricity Instant + Counter and set it to computed (idx 56):

Code: Select all

https://127.0.0.1/json.htm?type=command&param=udevice&idx=56&nvalue=0&svalue=2007;0
I waited a couple of minutes and entered the link again to simulate regular updates and then also the kWh is calculated.
Selection_045.png
Selection_045.png (16.61 KiB) Viewed 4825 times
It takes some time for the report graphs to update (every 5 minutes).

Re: Daily energy usage (KWH)

Posted: Monday 31 May 2021 11:43
by jonathan12
Weird!

I created a new virtual device. General electirc instant & counter.
Set it to computed. Tried your URL and it works!

I changed Easy ESP to sent the data to the new virtual device, and it works!
Thanks very very much!

Re: Daily energy usage (KWH)

Posted: Monday 31 May 2021 14:16
by waltervl
Great, have fun!

Re: Daily energy usage (KWH)

Posted: Saturday 25 March 2023 16:19
by MasMat
I think related to this, I have a similar problem.
I get watt readings from my inverter and I can forward those with MQTT. I have problems, I think, formating the message to Domoticz in NodeRed.
The semicolon corrupts the Javascript in NodeRed. I added the weird \u003B to get the symbol and just any number after it.

This works for a usage,electric dummy sensor:
===========
msg.payload = {"idx":164, "nvalue":0, "svalue":(msg.payload) +""};
return msg;
===========
Producing: {"idx":164,"nvalue":0,"svalue":"47"}

But this doesn't work (dummy, instant & counter, return, computed). The incoming value is watts (receiving same value as above:
===========
msg.payload = { "idx": 161, "nvalue": 0, "svalue": (msg.payload) +"\u003B" +"1"};
return msg;
===========
This produces what appears OK: {"idx":161,"nvalue":0,"svalue":"47;1"} but the sensor doesn't update.
Found this. Also doesn't work:
msg.payload = { "idx": 161, "nvalue": 0, "svalue": (msg.payload).toString() + ";" + (1).toString()};


Any ideas? Advise if a new thread is better than appending to this one.