Updating system parameters via dzVents

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

Moderator: leecollings

Post Reply
kini
Posts: 3
Joined: Saturday 30 November 2019 11:31
Target OS: Linux
Domoticz version: 2021.1
Location: Krasnoyarsk
Contact:

Updating system parameters via dzVents

Post 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
Attachments
meters.jpg
meters.jpg (36.08 KiB) Viewed 581 times
Last edited by kini on Monday 27 September 2021 7:36, edited 1 time in total.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Updating system parameters via dzVents

Post 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.
kini
Posts: 3
Joined: Saturday 30 November 2019 11:31
Target OS: Linux
Domoticz version: 2021.1
Location: Krasnoyarsk
Contact:

Re: Updating system parameters via dzVents

Post 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
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Updating system parameters via dzVents

Post 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. ;)
kini
Posts: 3
Joined: Saturday 30 November 2019 11:31
Target OS: Linux
Domoticz version: 2021.1
Location: Krasnoyarsk
Contact:

Re: Updating system parameters via dzVents

Post 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
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Updating system parameters via dzVents

Post 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).
Last edited by waltervl on Monday 27 September 2021 20:53, edited 1 time in total.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Updating system parameters via dzVents

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

Who is online

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