Page 1 of 1

How to change AddDBLogEntry parameter on existing counters?

Posted: Wednesday 03 November 2021 21:40
by andrehj
I intend to add yesterdays data to the P1 smart meter counter via a bash script.
Problem is that I have to set the AddDBLogEntry parameter to true to do that.

According to the manual I have to do that via a python plugin, as follows:

Code: Select all

Domoticz.Device(Name="MyCounter", Unit=1, Type=0xfa, Subtype=0x01, Options={"AddDBLogEntry" : "true").Create()
But I think that line creates a new device (not a big problem, but how do I prevent creating this device over and over?), and I haven't got a clue what I have to fill in for Type and Subtype.
And what what would a minimum plugin look like that only contains the line above?
Ideal would be an easier way to set this AddDBLogEntry parameter...

Thanks in advance for any help.

Re: How to change AddDBLogEntry parameter on existing counters?

Posted: Thursday 04 November 2021 9:36
by breizhcat
Hello

You can try to use API/Json provide by Domoticz.
https://www.domoticz.com/wiki/Domoticz_ ... mart_meter

You have to provide device Id and values. Then no device will be created and the current device will be updated.

BR

Re: How to change AddDBLogEntry parameter on existing counters?

Posted: Thursday 04 November 2021 19:51
by andrehj
Thanks, but that gives me two problems:
1. The counter only goes up. So if yesterday's value was 10 kWh, and today's value is 11 kWh, today's value will show as 1 kWh in Domoticz
2. The values come from a different system, which only calculates them after midnight. And when I enter them via the default json call (without a date), they will be assigned to the wrong date (one day later).

Both problems can be solved if I can use the method which lets me enter the historic data in the database, with the right date attached. However, to be able to do that I have to set the AddDBLogEntry parameter to true... But how?

Re: How to change AddDBLogEntry parameter on existing counters?

Posted: Friday 05 November 2021 22:33
by breizhcat
Hi

AFAIK AddDBLogEntry option is avaible only when you create your own plugin and your devices. Once it's created you juste have to manage data.

Another way to achieve this maybe: Update the domoticz.db file with sql statement. You won't be tied to the device and free to add any kind of entries. But, yes there is a but, you have to be sure about your data because you will be working directly on the database.