Daily energy usage (KWH)

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Daily energy usage (KWH)

Post 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
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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.
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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
Last edited by jonathan12 on Tuesday 25 May 2021 19:36, edited 1 time in total.
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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!
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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?
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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.
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post 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 4829 times
It takes some time for the report graphs to update (every 5 minutes).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jonathan12
Posts: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Daily energy usage (KWH)

Post 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!
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Daily energy usage (KWH)

Post by waltervl »

Great, have fun!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MasMat
Posts: 20
Joined: Saturday 09 March 2019 20:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Helsinki
Contact:

Re: Daily energy usage (KWH)

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest