Page 1 of 2

Bar charts of energy consumption

Posted: Thursday 12 October 2023 20:15
by Daro1003
I connected the energy meter structure to ESP + PZEM from Tasmota and it shows nicely the daily, monthly and annual energy consumption.
The problem is that in the monthly consumption chart I have a solid line.

I saw someone on the Internet post a bar chart from a given month where consumption was shown in bars for each day.
The question is how to create such a chart in domoticz?
Do you need Grafana for this or can it be set somehow in Domoticz?

Topic with pictures:
https://www.elektroda.pl/rtvforum/topic ... l#20767204

Re: Bar charts of energy consumption

Posted: Thursday 12 October 2023 23:31
by waltervl
What type of device is your Domoticz device that has these values?

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 17:55
by Daro1003
It is "custom sensor"
I would like to get total energy in the bars.

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 18:42
by willemd
General, custom sensors are stored in the percentage and percentage_calendar tables and therefore you get lines and daily min,max and avg values.

If you use a counter device (stored in the meter and meter_calendar tables), you will get the bars. You will get bars of the daily increase of the counter.

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 18:48
by Daro1003
How and where to change it?
Sensors and data are downloaded automatically by Tasmoticz and everything is added automatically. Is it possible to change this sensor?

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 20:11
by waltervl
That you should ask in Tasmota forum. How does Tasmota create the Domoticz device? Is it with MQTT Auto discover?

Edit: I read now you use the Tasmoticz Plugin. Please discuss this with the author. https://github.com/joba-1/Tasmoticz

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 21:07
by Daro1003
If I complete the Configure MQTT data in Tasmota and provide the IP and Domoticz port there, the sensors automatically appear in Domoticz. So it's Tasmoticz's fault?

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 21:13
by waltervl
Daro1003 wrote: Friday 13 October 2023 21:07 If I complete the Configure MQTT data in Tasmota and provide the IP and Domoticz port there, the sensors automatically appear in Domoticz. So it's Tasmoticz's fault?
Yes.

Re: Bar charts of energy consumption

Posted: Friday 13 October 2023 21:22
by Daro1003
So write a message to user Joba-1 with this problem? Or maybe a plugin update?

Is there any Tasmota forum?

Re: Bar charts of energy consumption

Posted: Saturday 14 October 2023 16:20
by waltervl
I think the best thing is to make a new issue on the GitHub repository https://github.com/joba-1/Tasmoticz/issues with reference to this forum topic.

Re: Bar charts of energy consumption

Posted: Saturday 14 October 2023 17:08
by Daro1003
Thanks for the link, I added a description of the problem with a link to this topic. I wonder if anything will be done about it.

Re: Bar charts of energy consumption

Posted: Saturday 14 October 2023 18:21
by willemd
Daro1003 wrote: Friday 13 October 2023 18:48 How and where to change it?
Sensors and data are downloaded automatically by Tasmoticz and everything is added automatically. Is it possible to change this sensor?
If you cannot change those created by Tasmoticz, you could create an additional device, type counter, and each time the Tasmoticz device changes you then also change this extra device using a dzvents script.

Re: Bar charts of energy consumption

Posted: Saturday 14 October 2023 22:15
by Daro1003
Unfortunately, I'm bad at writing scripts.

Re: Bar charts of energy consumption

Posted: Sunday 15 October 2023 13:05
by willemd
Daro1003 wrote: Saturday 14 October 2023 22:15 Unfortunately, I'm bad at writing scripts.
This will be one of the easiest. Use one device as trigger, take the value from that device, and then update the other.

Re: Bar charts of energy consumption

Posted: Sunday 15 October 2023 18:20
by waltervl
Better to have it fixed in the plugin. Should be not so difficult.
In tasmota.py this section should be changed I think.

Code: Select all

        'zählerstand_total':    {'Name':'Total Usage',  'Unit':'KWh',   'DomoType': 'Custom'},
        'zählerstand_tarif_1':    {'Name':'Tarif1 Usage',  'Unit':'KWh',   'DomoType': 'Custom'},
        'zählerstand_tarif_2':    {'Name':'Tarif2 Usage',  'Unit':'KWh',   'DomoType': 'Custom'},

Re: Bar charts of energy consumption

Posted: Sunday 15 October 2023 21:15
by hjheins
Hi just chiming in.
I also use this device, and had the same issues.
The solution indeed is a small script that you attach to a dummy device.
I basically hacked up a more complex script from SunnyBoy, and only made the bit referring to my Dummymeter device working.
See the attached file as for some reason the forum seems to interpret it all as external links in a code block.

Hendrik-Jan

Re: Bar charts of energy consumption

Posted: Sunday 15 October 2023 22:11
by waltervl
The real solution would be to use an energy counter device instead of a custom sensor. You also would get better reports.

Re: Bar charts of energy consumption

Posted: Sunday 15 October 2023 23:45
by joba1
Hi,

I'm willing to try your suggestion and you seem to know which type of device is needed.
Can you elaborate in terms of https://www.domoticz.com/wiki/Developin ... vice_Types which type would do what you want?
There are different flavors of counters with and without TypeName and even a kWh type.

Re: Bar charts of energy consumption

Posted: Monday 16 October 2023 9:58
by waltervl
Yes, kWh would be the correct device

It needs 2 values to update, svalue=POWER;ENERGY
POWER = current power (W)
ENERGY = Integer, total cumulative energy in Watt-hours (Wh)

So from the screenshot above
Power = 2+2+33=37 W
Energy = Energy Total = 21.224*1000 W

Re: Bar charts of energy consumption

Posted: Monday 16 October 2023 20:29
by joba1
I just created a pull request on my repo that should do what you want.

You can download/clone the test version plugin from the corresponding branch https://github.com/joba-1/Tasmoticz/tre ... s-counters

I tested, that the devices have a counter type and show correct values, but please check if the diagrams look as expected (I never used them before so I don't know what to expect)

You need to delete the old devices or the plugin won't recreate the new ones.
Better save a backup of the database before deleting them. I try to make a script to save the history from the old device to the new one.
So maybe the history can be restored later.