Last active
March 6, 2021 16:41
-
-
Save nearfatal1ty/2f560852b202d8a90b1103e2c7d29470 to your computer and use it in GitHub Desktop.
power bill calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
login to cps energy then go to this next url ---> https://secure.cpsenergy.com/mma/widgetDashBoard.jsp ---> ENERGY USE ( click it) ---> open developer tools, click the network section then click the circle with the slash thru it. its next to the red circle on the top left side | |
then change the year view to day view. look for a request with 'reads?' ignore 'hourly?' | |
right click it and copy it as a curl request. | |
within the url is the start date and end date, change them to whatever the billing period is on your cps bill | |
after the curl command pipe that shit to python pretty print aka 'python -m json.tool' | |
I personally like to save the result which is going to be json ( duh) | |
I grep for value then pipe to awk to get *just* the numerical reading | |
I then pipe to sed to remove that last comma sed 's/,*$//g' | |
then I do some slightly sketchy bash math | |
paste -sd+ | bc | |
( paste adds in a + ) | |
After that you will have your total KwH for the billing period | |
The URL will look something similar to whats below | |
curl 'https://cps.opower.com/ei/edge/apis/DataBrowser-v1/cws/utilities/cps/utilityAccounts/GUID/reads?startDate=2021-01-29&endDate=2021-02-28&aggregateType=quarter_hour&includeEnhancedBilling=false&includeMultiRegisterData=false' \ | |
-H 'Connection: keep-alive' \ | |
-H 'DNT: 1' \ | |
-H 'x-requested-with: XMLHttpRequest' \ | |
-H 'accept-language: en-US' \ | |
-H 'User-Agent: Jaime waves at the web log parsers :)' \ | |
-H 'opower-selected-entities: ["urn:opower:customer:uuid:GUID"]' \ | |
-H 'Accept: */*' \ | |
-H 'Origin: https://secure.cpsenergy.com' \ | |
-H 'Sec-Fetch-Site: cross-site' \ | |
-H 'Sec-Fetch-Mode: cors' \ | |
-H 'Sec-Fetch-Dest: empty' \ | |
-H 'Referer: https://secure.cpsenergy.com/' \ | |
-H 'Cookie: cookie-check=true; JSESSIONID=GUID; __direct-domain-access-fix=applied' \ | |
--compressed | |
Assuming you saved the resulting json this is the command needed to extract the data | |
cat feb_power_usage.json | grep value | awk '{print $2}' | sed 's/,*$//g' | paste -sd+ | bc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment