DADEP - Day ahead energy prices - actual costs (DzVents script)

Moderator: leecollings

Post Reply
Hansbit
Posts: 36
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

DADEP - Day ahead energy prices - actual costs (DzVents script)

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

Scherm­afbeelding 2023-07-20 om 15.38.56.png
Scherm­afbeelding 2023-07-20 om 15.38.56.png (394.34 KiB) Viewed 1647 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/.
bldewit
Posts: 59
Joined: Tuesday 09 May 2017 23:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post by bldewit »

Nice!

Verstuurd vanaf mijn SM-T590 met Tapatalk

-‐----------------------------------------------------------
Running on rPi 3b (main) and rPi 2b (somfy), both RFLink
IthoRemote, Xiaomi Gateway, KAKU
Martini77
Posts: 23
Joined: Tuesday 28 May 2019 23:08
Target OS: Linux
Domoticz version: 2023.2
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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?
Running Domoticz:
- Main @ LXC (Proxmox);
- Secondary @ Pi4B (for backup / test / alerts)
- Synology (Docker) for alerts on main
User avatar
waltervl
Posts: 5376
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Martini77
Posts: 23
Joined: Tuesday 28 May 2019 23:08
Target OS: Linux
Domoticz version: 2023.2
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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?
Running Domoticz:
- Main @ LXC (Proxmox);
- Secondary @ Pi4B (for backup / test / alerts)
- Synology (Docker) for alerts on main
User avatar
waltervl
Posts: 5376
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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&param=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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Martini77
Posts: 23
Joined: Tuesday 28 May 2019 23:08
Target OS: Linux
Domoticz version: 2023.2
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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
Running Domoticz:
- Main @ LXC (Proxmox);
- Secondary @ Pi4B (for backup / test / alerts)
- Synology (Docker) for alerts on main
User avatar
waltervl
Posts: 5376
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
roelvdh
Posts: 37
Joined: Saturday 18 January 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

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

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post by waltervl »

Did you check the Enever hardware gateway in Domoticz?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
roelvdh
Posts: 37
Joined: Saturday 18 January 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

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

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post by waltervl »

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
roelvdh
Posts: 37
Joined: Saturday 18 January 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

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

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
roelvdh
Posts: 37
Joined: Saturday 18 January 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: NL
Contact:

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

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

Re: DADEP - Day ahead energy prices - actual costs (DzVents script)

Post 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
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: No registered users and 0 guests