Page 1 of 1
DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Monday 24 July 2023 11:47
by Hansbit
I've written a dzVents script for Domoticz for counting your electricity use (in Euro's) during the day. Use with 'Dynamic' provider prices (electric hourly, gas daily (6-6h)). Prices are obtained directly from Entso-E and EEX.
Cost counters are updated every 5 min. Watch your realtime electricity, gas and water costs. Option to send a daily report with Telegram.

- Schermafbeelding 2023-07-20 om 15.38.56.png (394.34 KiB) Viewed 1985 times
One special field 'Electricity color' is filled with a color. Electricity color changes during the day from BLUE (normal), RED (more than 10% higher than day avarage) or GREEN (more than 10% cheaper than day avarage) - You can switch devices at cheap of expensive times, or install a RGB lamp to indicate to your family
During the day, the counter 'Self produced percentage' is updated. It is calculated between used electricity and power obtained from your solar panals. Very nice to follow the percentage change when the sun shines, or car is being charged.
Script can be found at Github
https://github.com/H4nsie/dadep/.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Monday 24 July 2023 22:13
by bldewit
Nice!
Verstuurd vanaf mijn SM-T590 met Tapatalk
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Sunday 15 September 2024 11:20
by Martini77
With the new version of Domoticz that captures the costs of power consumption in combination with the Enever hardware, the calculation of daily costs with dynamic prices could be fetched from the DB as this is also shown on the log...
Is there any (wip?) way this could be done in a DzVents script?
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Sunday 15 September 2024 18:41
by waltervl
?? I don't fully understand.
If you put the Entso-E and EEX current prices by the script in a Domoticz custom sensor you can use that as the input for the new Domoticz way of actual energy cost calculation.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Tuesday 17 September 2024 10:32
by Martini77
waltervl wrote: ↑Sunday 15 September 2024 18:41
?? I don't fully understand.
If you put the Entso-E and EEX current prices by the script in a Domoticz custom sensor you can use that as the input for the new Domoticz way of actual energy cost calculation.
The current (dynamic) price you can easily get into the Enever (hardware) devices
It's about the ability of reporting the daily costs through eg. a Telegram message. The daily costs are stored in the db and are shown on the Energy dashboard correctly, so far so good.. The P1 sensor/device Log will show this as a calculation per hour and also per day as history including today's costs (so far). But like there is attributes counterDeliveredToday and counterToday, there is no such for costs, correct?
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Tuesday 17 September 2024 10:39
by waltervl
There is indeed no dzvents function to report the daily costs. There is however now in the json result of API call getdevices a cost entry.
Code: Select all
/json.htm?type=command¶m=getdevices&rid=IDX
So it should be possible to have a dzvents script call the API and get the cost value form the device and send it to telegram.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Tuesday 17 September 2024 20:51
by Martini77
Thanks Walter, the API call indeed shows the daily costs.
Including this API call with json stripping in the DzVents scripts is a bit more difficult as I need to read 2 devices and domoticz.openURL() is asynchronous.. For some reason this does not work:
-- Get P1 and Solar device state
json = assert((loadfile "/root/domoticz/scripts/lua/JSON.lua")())
-- Read P1 status
local api_call=assert(io.popen('curl
http://localhost:7080/json.htm?type=com ... s&rid=1211'))
local json_response = assert(api_call:read('*all'))
api_call:close()
local jsonStatus_p1_meter = assert(json:decode(json_response))
print('P1 costs = '..jsonStatus_p1_meter.result[1].price)
Getting an error in the log on the last line; attempt to index a nil value (field 'result')
(and yes, I have whitelisted 127.0.0.*;localhost in the settings and also tried to curl the domoticz ip + 127.0.0.1)
** Update; executed curl in shell and it gives me the ERR response, so looking into that..

** Update 2; fixed! the curl for the Domoticz API needed some quotes around the address. Next, the response result is in a table format, so take result[1].price from the json to get the costs of today
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Tuesday 17 September 2024 22:29
by waltervl
You can also request 2 idx on the same time., Idx separated by ,
Or put the 2 devices in a room and use the room filter. Check the wiki for more details.
https://www.domoticz.com/wiki/Domoticz_ ... fic_device
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 11:32
by roelvdh
Just started using this script and I like it. Some minor things:
1. Gas prices for today and tomorrow are seemingly not coming in.
2. In dadep.lua the line
Code: Select all
dz.helpers.telegramnote(dz, message)
returns a Domoticz error:
Code: Select all
Error: dzVents: DADEP: /home/pi/domoticz/scripts/dzVents/scripts/dadep.lua:316: attempt to index a nil value (field 'helpers')
Note: The Telegram test in Domoticz worked fine
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 12:34
by waltervl
Did you check the Enever hardware gateway in Domoticz?
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 14:58
by roelvdh
Quite silly, but: No. I must be missing something. I don't have Enever in Settings|Meters/Counters. I filled the 3 lines in table (Dynamische) Prijsberekening and I assumed DADEP would take care of the rest fetching prices from ENTSOE and EEX. I didn't see a reason for Enever this way, but I am probably wrong. Please clarify. The energy prices are working in a way, but gas prices all are nil.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 15:25
by waltervl
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 15:53
by roelvdh
That says I should configure Enever in Settings|Meters/Counters, but I don't have that.
Edit: Sorry, that is new hardware to be installed, the docs are not quite clear about that.
But I still wonder why this should be necessary. DADEP does exactly that.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 16:08
by waltervl
You can do whatever you want but with enever you dont have to script something and manually add virtual devices, only configure Enever which creates those devices. But again totally up to you.
Edit: I also updated the Enever wiki to make it more clear with regard to the dynamic energy cost calculations and Energy dashboard.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 16:33
by roelvdh
OK, thank you Walter. As this post is about DADEP, not Enever, I will stick to that and try to solve the problems I encountered. I will change over to Enever if I don't solve those problems in real time. My second problem, about Telegram notification, still exists, but when I change DADEP for Enever that will go away as well. Thanks again for educating me about Enever.
Re: DADEP - Day ahead energy prices - actual costs (DzVents script)
Posted: Thursday 10 October 2024 17:19
by waltervl
roelvdh wrote: ↑Thursday 10 October 2024 11:32
Just started using this script and I like it. Some minor things:
1. Gas prices for today and tomorrow are seemingly not coming in.
2. In dadep.lua the line
Code: Select all
dz.helpers.telegramnote(dz, message)
returns a Domoticz error:
Code: Select all
Error: dzVents: DADEP: /home/pi/domoticz/scripts/dzVents/scripts/dadep.lua:316: attempt to index a nil value (field 'helpers')
Note: The Telegram test in Domoticz worked fine
It looks like a helper file was created with a telegramnote function. see also wiki
https://www.domoticz.com/wiki/DzVents:_ ... _functions
If that helper file is not in the repository it will not work. That specific line was also commented out in the source so probably also not to be used as such.
Dzvents also has a build in notify function that can be used: dz.notify(subject, message [,priority][,sound][,extra][,subsystem][,delay]
As subsystem you have to use then dz.NSS_TELEGRAM