Perfect! I just installed HA last weekend, and I’ve been looking for a way to extract my info from CSU for tracking purposes for all three (gas, water, electric).
Happy to test this! Also have some proficiency in Python so might even be able to help with coding.
Here is what I wrote so far … It makes a BUNCH of calls to login and set cookie tokens and then finally it will make a call to download stuff… possibly hardcoded some account numbers in there now that I think of it.
# Download commnad
data['ctl00$ContentPlaceHolder1$UI_ExternalUserControl1$btnCsv'] = 'Download Spreadsheet Data'
# Gas Meter
data['ctl00$ContentPlaceHolder1$UI_ExternalUserControl1$dlLocationID'] = 'N:2646052025:NN'
return data
Like that looks like maybe something hardcoded… but if you are decent with python give it a once/twice/thrice over.
Thanks for posting this. I’ve confirmed your code works great for me, and your intuition is dead on, the ID in the following line will differ based on each person’s account:
Specifically, the ID 2646052025. Probably need to write some logic that parses the descriptions looking for ‘GAS’, ‘ELECTRICITY’, or ‘WATER’ and then programatically getting the ID based on what you find for the value.
Good news is I was able to use your code and simply switch this ID between any three of those choices in my account and it worked great. Nice job!
My coding skills are very elementary. But I’ll be following this (if there’s anything still going on) as I just moved to Colorado Springs and would love to pull my energy usage into Home Assistant.
I was initially trying to stay away from anything selenium/puppeter but its SOOO MUCH simpler to go this route
I started a new repo. The only thing that’s a bit funky is I have solar so I have a generated/used option which I haven’t figured out for energy yet… so this one right now does gas.
Since you aren’t allowed to scrape stuff any longer I was thinking I could ultimately make an integration that “hits” a local endpoint which is doing the scraping for you
I ended up going with an “extreme” solution for this, but it works.
We finally got solar panels installed, and the integration reports both power produced by the panel and consumed by my house overall. Took me a while to get it working, and it can only update once every 5 seconds (that’s the fastest the solar panel integration is permitted to log in to obtain data), but I now have it fully integrated into my HA Energy dashboard, and can get a pretty decent idea of my home’s power usage, as well as power produced and pushed back up to the grid.
If anyone wants it, I have a complete write-up of how I did it, using the Enphase Envoy integration (the HACS version, as the “official” one doesn’t support my panel). But if I do that, it’ll be a new post, not another reply to this one.