How to change AddDBLogEntry parameter on existing counters?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

How to change AddDBLogEntry parameter on existing counters?

Post 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.
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: How to change AddDBLogEntry parameter on existing counters?

Post 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
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: How to change AddDBLogEntry parameter on existing counters?

Post 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?
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: How to change AddDBLogEntry parameter on existing counters?

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

Who is online

Users browsing this forum: No registered users and 1 guest