when does Dzvents do database commit?

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

Moderator: leecollings

Post Reply
willemd
Posts: 741
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

when does Dzvents do database commit?

Post by willemd »

When are device updates that are done in DzVentz scripts committed to the database?

I am running a script where I update a device. I print the device value before and after the update statement for debugging purposes. The print shows the same value.

I am then running the script a second time. The before-value then shows the value after the previous update.

So my conclusion is that the database commit takes place when the script finishes?

Does the database also have locking issues? How does domoticz handle this? I am asking because mostly the database update occurs without problems, but sometimes the new value is not inserted into the database, even though the script runs fine and prints all debug messages. Even the latest time the device is updated changes, but the actual value does not.
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: when does Dzvents do database commit?

Post by waltervl »

I think it is discussed before and it seems a refresh issue within DzVents.
You can check it by changing a value by DzVents and check it in the webUI, it should change (and so committed in the database). It is changed but dzVents will not update itself somehow.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 741
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: when does Dzvents do database commit?

Post by willemd »

I searched for it but could not find a topic on it in the forum. The refresh is no problem, as long as I know that the device is not updated during the script, so I should not query it again and assume it was updated. I can easily work around this.

Still this leaves the issue that sometimes the new values don't seem to be committed to the database at all, even though the timestamp of the device change is updated and the debug info shows the correct calculation.

In would assume any locking is at record level? Not database or table level? So multiple scripts can run correctly as long as they don't update the same record ?

Could any of the internal processes get in the way? I see for example a new value inserted into the Meter table every 5 minutes, even if there is no change and this is a dummy device that only is used by my script. If my script tries to insert a value while the internal process is inserting a value at the same time or just before/after, what will happen? Could my inserted value get lost?
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: when does Dzvents do database commit?

Post by waltervl »

Therefore you need to go into the source code. See https://github.com/domoticz/domoticz/bl ... .cpp#L6439
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest