Page 1 of 1

Updating system parameters via dzVents

Posted: Monday 27 September 2021 3:43
by kini
Hello everyone!
I have a script that reads the readings from the PZEM-004t and the kWh cost from the Domoticz settings. At the end, the monthly electricity bill is calculated. Everything works great, I like it.
There was a desire to adjust the tariff in automatic mode. The electricity supplier has a website that publishes current tariff prices. I can read them from the site, but I want to write them to "Costs T1" and "Costs T2" in the "Meters / Counters" tab of the settings through the dzVents script. Is it possible to do this without having to edit the Domoticz database?
P.S. I tried to make the following request to the database from dzVents:

Code: Select all

'/usr/bin/sqlite3 /opt/domoticz/domoticz.db "UPDATE Preferences SET nValue=' .. price .. ' WHERE key="' .. key .. '"'
It didn't work either, the data didn't update. If you run the same command from the command line, the data is updated
P.P.S. I managed to update the data through the request, my mistake was in the wrong pair of quotes in the request. But it still seems to me that this is not a very good way to update data in settings

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 7:21
by EddyG
I think that those costs are a kind of dummy. I think that all years, months and days are calculated with the same costs.
I cannot find any yearly, monthly or daily calculated costs in a table, but may be I am not looking good enough.

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 7:37
by kini
EddyG wrote: Monday 27 September 2021 7:21 I think that those costs are a kind of dummy. I think that all years, months and days are calculated with the same costs.
I cannot find any yearly, monthly or daily calculated costs in a table, but may be I am not looking good enough.
My electricity cost has increased several times in recent years

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 11:08
by EddyG
Luckily my costs only change one a year. So I do that once a year manually. This way you can save XLS files just before that and use the 'old' costs for calculating in Excel if you want to, but it does not change the bill from the utilities company. ;)

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 18:46
by kini
I apologize, but the question is not who has what tariffs, but how to save the data received from the site into the system variables CostEnergy and CostEnergyT2

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 19:17
by waltervl
Normally all Domoticz actions are handled by API calls https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s

Unfortunately this updating tariff value action is not documented yet (if it exists).

Re: Updating system parameters via dzVents

Posted: Monday 27 September 2021 20:11
by EddyG
The way you updated the costs is perfect ok, but remember those values are used for ALL costs (previous months and years)
Only decent use is for current energy values.
If it does not work from dzVents: put a 'sudo' in front of the sqlite3 command.