Daily Energy usage cost
Moderator: leecollings
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Daily Energy usage cost
Hi all,
So i've been able to graph my energy usage using the owl micro but i wondered if theres anyway i can get domoticz to automatically work out how much it's costing me.
i pay 14.89p per unit.
many thanks
So i've been able to graph my energy usage using the owl micro but i wondered if theres anyway i can get domoticz to automatically work out how much it's costing me.
i pay 14.89p per unit.
many thanks
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: Daily Energy usage cost
AT settings ==> meters/counters fill in the cost/kWh.
On the device click on log and then report
On the device click on log and then report
Greetings McMelloW
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
ah awesome thank you 
i also have a daily meter charge of 14.09p i don't suppose there's anyway to get that to add to the daily cost?

i also have a daily meter charge of 14.09p i don't suppose there's anyway to get that to add to the daily cost?
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: Daily Energy usage cost
I use an average figure per kWh including tax, meter charge etc. This calculated according to the bills of the past few years.
Feel free to think of something clever and post it.
Feel free to think of something clever and post it.
Greetings McMelloW
-
- Posts: 26
- Joined: Thursday 30 June 2016 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Amsterdam
- Contact:
Re: Daily Energy usage cost
good idea, if you got the energy bill of last year, you can probably just add a markup for the fixed costs like meter rent, delivery&transport costs etc to the price per unit
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: Daily Energy usage cost
Even better if you have energy bills from a couple of years.
Greetings McMelloW
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: Daily Energy usage cost
Here's a simple python script I use which calculates energy cost based on cumulative energy today, and which allows for fixed and variable cost elements:
I run this once a minute from crontab - I would have liked to use lua (so this would update every time the Owl device updates), but I couldn't work out how to extract 'CounterToday'.
Here is an example of my output:

(of course this can be changed for other currencies)
- Spoiler: show
I run this once a minute from crontab - I would have liked to use lua (so this would update every time the Owl device updates), but I couldn't work out how to extract 'CounterToday'.
Here is an example of my output:

(of course this can be changed for other currencies)
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
MikeF you hero
this is exactly what i was thinking of but just didn't have the knowledge to put it together.
so i would copy the code you have supplied and save it to a file called energy_cost.py
Once i have made the changes i would run:
choose nano and add the following line to the bottom of the file:
sorry where would i find the json for the device?
i can see the following in the logs

this is exactly what i was thinking of but just didn't have the knowledge to put it together.
so i would copy the code you have supplied and save it to a file called energy_cost.py
Once i have made the changes i would run:
Code: Select all
crontab -e
Code: Select all
*/1 * * * * /usr/bin/python2.7 /sbin/energy_cost.py >> /var/log/energy_cost.log 2>&1
sorry where would i find the json for the device?
i can see the following in the logs
Code: Select all
2018-03-31 16:46:43.495 RFLink: 20;E5;OWL_CM180;ID=003D;WATT=00f1;KWATT=00026bad;
2018-03-31 16:46:43.497 (RFLink Gateway) General/kWh (Power Monitor)
Last edited by garethiowc on Monday 06 May 2019 22:10, edited 2 times in total.
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: Daily Energy usage cost
Hi garethiowc,
First of all, make sure you change the lines in 'Domoticz variables' section of the code to your values - you'll need to find the idx of your Owl device, and also set up a text sensor in Domoticz, and get its idx.
Once you've got the Domoticz idx of your Owl device, type the following into your browser (replacing the angle brackets with your values):
http://<Domoticz ip:port>/json.htm?type=devices&rid=<Owl idx>
(e.g., http://192.168.0.63:8080/json.htm?type=devices&rid=240)
- this is the json output. If you can see a line like this:
then you should be good to go.
Your crontab steps look OK.
First of all, make sure you change the lines in 'Domoticz variables' section of the code to your values - you'll need to find the idx of your Owl device, and also set up a text sensor in Domoticz, and get its idx.
Once you've got the Domoticz idx of your Owl device, type the following into your browser (replacing the angle brackets with your values):
http://<Domoticz ip:port>/json.htm?type=devices&rid=<Owl idx>
(e.g., http://192.168.0.63:8080/json.htm?type=devices&rid=240)
- this is the json output. If you can see a line like this:
Code: Select all
"CounterToday" : "9.211 kWh",
Your crontab steps look OK.
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
Thanks MikeF
just got the script working
apt-get install python-requests
source ~/.bashrc
just got the script working
apt-get install python-requests
source ~/.bashrc
Last edited by garethiowc on Monday 06 May 2019 21:57, edited 2 times in total.
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
is the fixed cost the daily meter rental charge or am i understanding that wrong?
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: Daily Energy usage cost
Trying to get this to work with Toon (Eneco), but only get 0.01 pence costs. Of course I wouldn't mind that 

Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost

i had to specify the python3 path to get it to work in cron using the following
*/1 * * * * /usr/bin/python3.5 /sbin/energy_cost.py >> /var/log/energy_cost.log 2>&1
added a log output for errors when the cron job runs
next thing to work out would be a weekly and monthly cost output

-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: Daily Energy usage cost
Have you checked that you've got a variable 'CounterToday' (or change it to something similar) that's producing values to a similar order of magnitude (e.g., 6.392 kWh)? and that your fixed / variable costs are similar? (Of course, you can input these in cents, and change the script to display in € rather than £.)
-
- Posts: 28
- Joined: Sunday 03 December 2017 23:02
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
Does any one know if the data sting will reset monthly or just keeps counting?"CounterToday" : "6.6 kWh",
"CustomImage" : 0,
"Data" : "167.985 kWh",
-
- Posts: 80
- Joined: Saturday 19 March 2016 21:12
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Daily Energy usage cost
Data is Just counting, so not usable for monthly costs.garethiowc wrote: ↑Monday 02 April 2018 0:22Does any one know if the data sting will reset monthly or just keeps counting?"CounterToday" : "6.6 kWh",
"CustomImage" : 0,
"Data" : "167.985 kWh",
Screen Shot 2018-04-01 at 23.21.11.png
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: Daily Energy usage cost
I guess you could get the script to save the cumulative Data value at the beginning of each month
- if 'day' = '01' and 'time' = '00:00' then write Data to uservariable 'MonthStart'
and then subtract MonthStart from current value of Data every time the script runs...
Haven't tried it though!
- if 'day' = '01' and 'time' = '00:00' then write Data to uservariable 'MonthStart'
and then subtract MonthStart from current value of Data every time the script runs...
Haven't tried it though!
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: Daily Energy usage cost
This is what I have within the device:
Code: Select all
{
"ActTime" : 1522779214,
"AstrTwilightEnd" : "22:20",
"AstrTwilightStart" : "05:12",
"CivTwilightEnd" : "20:53",
"CivTwilightStart" : "06:38",
"DayLength" : "13:06",
"NautTwilightEnd" : "21:35",
"NautTwilightStart" : "05:56",
"ServerTime" : "2018-04-03 20:13:34",
"SunAtSouth" : "13:05",
"Sunrise" : "07:12",
"Sunset" : "20:19",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"Counter" : "3532.785",
"CounterDeliv" : "0.000",
"CounterDelivToday" : "0 kWh",
"CounterToday" : "5.709 kWh",
"CustomImage" : 0,
"Data" : "1744933;1787852;0;0;517;0",
"Description" : "",
"Favorite" : 0,
"HardwareID" : 35,
"HardwareName" : "Toon",
"HardwareType" : "Toon Thermostat",
"HardwareTypeVal" : 34,
"HaveTimeout" : false,
"ID" : "1",
"LastUpdate" : "2018-04-03 20:13:13",
"Name" : "Electra",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Energy",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "P1 Smart Meter",
"TypeImg" : "counter",
"Unit" : 1,
"Usage" : "517 Watt",
"UsageDeliv" : "0 Watt",
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "199"
}
],
"status" : "OK",
"title" : "Devices"
}
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: Daily Energy usage cost
My python script uses CounterToday, so if for instance your unit cost is 14.89 and fixed cost is 14.09 (garethiowc's example), then you should get:EdwinK wrote: ↑Tuesday 03 April 2018 20:14 This is what I have within the device:
Code: Select all
{ ... "CounterToday" : "5.709 kWh", ... }
cost = (5.709 * 14.89 + 14.09 ) / 100 = 0.99
Can you check your values and your script again?
Who is online
Users browsing this forum: No registered users and 1 guest