Billing Period for electricity consumption & cost per day, month and year

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

Moderator: leecollings

Post Reply
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Billing Period for electricity consumption & cost per day, month and year

Post by McMelloW »

Hi to all,

As far as I understand, this script uses the calendar year as the period. As anybody changed this to the Energy Billing period. If so can you tell me how?

In my opinion it is more logic to see the usage and cost during the billing period instead of the calendar period.
Greetings McMelloW
User avatar
waltervl
Posts: 5776
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Billing Period for electricity consumption & cost per day, month and year

Post by waltervl »

You mean this script I suppose viewtopic.php?t=33066

I have a script running to get my gas consumption from a specific day (the day my gas tank was filled up again)
I use a, so it seems, undocumented option of the graph API call for counters that uses a range from date to date: &range=YYYY-MM-DDTYYYY-MM-DD
Notice the "T" between the dates.... (Edit: It is documented now...)

The json should look something like this to get data from 20 januari to today:

Code: Select all

/json.htm?type=command&param=graph&sensor=counter&idx=513&range=2024-01-20T2024-06-021"
I use a function to get the data:

Code: Select all

        local function triggerJSON(idx,from,to)
            local  URLString   = dz.settings['Domoticz url'] .. 
                                 "/json.htm?type=command&param=graph&sensor=counter&idx=" .. idx ..
                                 "&range=" .. from .. "T" .. to
            dz.openURL({    url = URLString,
                            method = "GET",
                            callback = "history" })    
         end
I put the last tank date in a user variable that I can change easily withot changing the script. Get that date and trigger the jsaon call from tan date to today.

Code: Select all

local LastTankDate = dz.variables('LastTankDate').value
local dateFormat = "!%Y-%m-%d"
triggerJSON(myDevice, LastTankDate, os.date(dateFormat))
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Billing Period for electricity consumption & cost per day, month and year

Post by McMelloW »

waltervl wrote: Friday 21 June 2024 18:36 You mean this script I suppose https://www.domoticz.com/forum/viewtopic.php?t=33066

I have a script running to get my gas consumption from a specific day (the day my gas tank was filled up again)
I use a, so it seems, undocumented option of the graph API call for counters that uses a range from date to date: &range=YYYY-MM-DDTYYYY-MM-DD
Notice the "T" between the dates.... (Edit: It is documented now...)
Thanks for your reply. Yes it is the script of that topic. I found this on wiki API/JSON page. It all looks a but complicated to me, but I will dig into it and see or it brings me to a solution.
Greetings McMelloW
Post Reply

Who is online

Users browsing this forum: Wiers and 1 guest