Page 1 of 1

when does Dzvents do database commit?

Posted: Thursday 01 September 2022 13:25
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.

Re: when does Dzvents do database commit?

Posted: Thursday 01 September 2022 14:07
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.

Re: when does Dzvents do database commit?

Posted: Thursday 01 September 2022 14:34
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?

Re: when does Dzvents do database commit?

Posted: Thursday 01 September 2022 15:27
by waltervl
Therefore you need to go into the source code. See https://github.com/domoticz/domoticz/bl ... .cpp#L6439