Question on the WIki: AddDBLogEntry / historic data addition

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
JustDude
Posts: 16
Joined: Thursday 23 February 2023 18:15
Target OS: Linux
Domoticz version: Latest
Location: NL
Contact:

Question on the WIki: AddDBLogEntry / historic data addition

Post by JustDude »

Hi,

I wanted to add historic data to my P1 (gas and Electra) via the following instruction on the Wiki (nice documentation by the way):
Note on counters
Usually, counters are updated daily to feed week/month/year history log views. Starting version 4.11774, if you want to disable that behavior to control everything from an external script or a plugin (already the case for managed counter), you can set the "DisableLogAutoUpdate" device option to "true", for instance in a Python plugin:
Domoticz.Device(Name="MyCounter", Unit=1, Type=0xfa, Subtype=0x01, Options={"DisableLogAutoUpdate" : "true").Create()
Starting version 4.11774, you can too directly insert data in in history log. Set the "AddDBLogEntry" device option to "true", for instance in a Python plugin:
Domoticz.Device(Name="MyCounter", Unit=1, Type=0xfa, Subtype=0x01, Options={"AddDBLogEntry" : "true").Create()

and:
Then, depending on counters, you can insert values in history log. For most counters:
/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=COUNTER;USAGE;DATE
Now I looked at the Domoticz code and the AddDBLogEntry parameter is only used for Managed counters, nowhere else.
Before I do a try out on a copy of my DB, I want to make sure if it is possible to add historical data like this for current and daily usage.
Or is it limited to managed counters as the code suggests
---
Measuring is knowing
willemd
Posts: 642
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Question on the WIki: AddDBLogEntry / historic data addition

Post by willemd »

the if condition in the code is

Code: Select all

if ((devType == pTypeGeneral && subType == sTypeManagedCounter) || (options["AddDBLogEntry"] == "true"))
so this states you can do the inserts if it is a managed counter (even without setting AddDBLogEntry)
but you can also do the inserts on other counters if you set the AddDBLogEntry option.

I did some testing a few months ago and as result the documentation was adapted. If I remember well it indeed also worked for other counters.
It is easy to test, just update the options field in devicestatus (for example with sqlite3. Make a backup beforehand !!) to the string indicated and run the json statement.

see also
https://github.com/domoticz/domoticz/issues/5447
https://github.com/domoticz/domoticz/issues/5479
User avatar
JustDude
Posts: 16
Joined: Thursday 23 February 2023 18:15
Target OS: Linux
Domoticz version: Latest
Location: NL
Contact:

Re: Question on the WIki: AddDBLogEntry / historic data addition

Post by JustDude »

Thanks tons! That was indeed my mistake, I misread the statement.
I want to try it out on a test install indeed before live.
---
Measuring is knowing
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest