Pinned Solved

Can we get access to the live usage API?



Show first post

124 replies

Hey @VibroAxe

If you can send @Tim_OVO a PM with your account number, name and DoB - he'll add you to a list for any future API trials we might do!

Cheers,
Emily
Userlevel 2
You already have an internal RESTful API that your node.js framework uses for callbacks withing the Usage page et al. And this JSON return is all that you need for a Node RED flow.

Just in case anyone is interested in doing this, the JS code in the graphics display package running on your browser does a callback to retrieve the JSON data which it uses to draw the pretty usage graphs. For this to work your session must have been properly authenticated with your account and passwork because the API does a security check to ensure that any request for your data has the correct session cookies so that only you can see your data. Notwithstanding this, once your browser has established a session, then you can execute a query of the following format in your browser to pull this data down. You can then open this in your favourite spreadsheet application and manipulate / store the data as your see fit.
code:
https://live.ovoenergy.com/api/live/meters/MPAN/consumptions/aggregated?from=FROM&to=TO&granularity=HH

where the MPAN comes from your profile and the FROM and TO fields are of the format YYYY-MM-DDTHH:00:00.000Z.
The API does not seem to limited the range size, so I do this once a month and use a script to load the data into my Home Automation MySQL database. Please don't abuse this or I am sure that the developers will apply extra validation. I personally think that 1 query a month is better than going on a couple of times a day as I was doing previously.

Advanced programmers could no doubt script the whole session connection to recover the session cookies. I am one, but I haven't bothered.
Userlevel 4
Badge
Thanks for the url @TerryE. It works a treat! And I have retrieved usage for both electricity and gas.
Given that I check MyUsage on the website several times each day anyway, running this daily shouldn't cause Ovo any additional overheads. However, I run nodeRed on my raspberry pi, so I will have to figure out how to set up a session in order to fully automate this.
Userlevel 2
@SianiAnni At the moment, I cludged this by running the query in my browser after creating my session interactively and then using a small perl script to upload this into my nodered db.

I haven' bother to retro-engineer the sequence of POST requests to establish fresh set of session cookies for each AJAX callback to work as retro-engineering this is all a bit of a dog, and iIt could take me a day to do this so there isn't the payback: one day's work to save a minute or so every month.

Which is why we really need to wait for the proper API if you want to automate this fully.
Userlevel 3
@ErTnEc, this is exactly what I want to be able to do. I use NodeRED to poll darksky.net for current weather readings. Can you send me your python script to play with?

Sorry I've had a hectic time lately and not had chance to pick this back up.

https://gist.github.com/PaulW/7f3ce29c3469757c26504b572597a45c

I still need to add in some extra error handling (specifically around initial auth requests as it takes a while for the authtoken to be fully active it seems) but it's a fairly simple process which people can easily build upon if need be.
It's been a bit quiet here. Quite a long trial it seems. @Tim_OVO is there any further news?
Just PM'd you Tim account number ending in ****910, very interested in the API trials for integration into our home automation system.
Userlevel 2

Advanced programmers could no doubt script the whole session connection to recover the session cookies. I am one, but I haven't bothered.


Further to @ErTnEc's git contribution, I have updated this to do the V2 API for historic consumption. I run the following script daily to download the previous day's half-hourly consumption into the MySQL DB that underpins my NodeRED installation: load_readings.py.

There's an issue with NodeRED HTTPrequest which causes logon problems so I haven't got the native NodeRED version working. Sorry. It's not worth my spending time on this because I will moving supplier when my contract ends. I really like OVO, but a 30+% price hike is just too much, when other suppliers offer better deals.
Thanks TerryE works a treat.
Userlevel 2
works a treat.
@jdenver, If you check, I've updated the script slightly. What I've found is that the Smart Meter sends its SMS message once a day about 02:00, so the consumption figures for the previous day are only available after that. The message occasionally fails for whatever reason, so you can miss a day, but it does retry at some point. So what I've done is to query the max DTS from my readings table and set the FROM to 30 mins after the last end. That way, the reading will catch up and you don't end up dropping data in your table.

I am note sure why the NodeRED native version fails to authenticate, but it is just easier to trigger the flow by a cron injector (actually I use node-red-contrib-pkjq as this is better maintained) and then exec the python script.
Thanks Terry, Im quiet new to Python but learning fast. Ive not ventured into NodeRED yet. When I ran the script there was issues with MySQL but the data was displayed on the screen as it should.

Trying to work out how to adapt the code to capture gas data.
Userlevel 4
Badge

Advanced programmers could no doubt script the whole session connection to recover the session cookies. I am one, but I haven't bothered.


Further to @ErTnEc's git contribution, I have updated this to do the V2 API for historic consumption. I run the following script daily to download the previous day's half-hourly consumption into the MySQL DB that underpins my NodeRED installation: load_readings.py.
There's an issue with NodeRED HTTPrequest which causes logon problems so I haven't got the native NodeRED version working. Sorry. It's not worth my spending time on this because I will moving supplier when my contract ends. I really like OVO, but a 30+% price hike is just too much, when other suppliers offer better deals.


Thanks for this. I haven't managed to get your load_readings.py script to run on Windows, but as long as I'm already logged into MyOvo, pasting a handcrafted url from your script certainly returns the data, which is great because the url which I was using last winter no longer works! I copy the displayed data into a python script which then parses and outputs something human readable and graphable into a csv file.
That reminds me. Need to sort out leaving for a better company.
Not happy with the fact I've been on the waiting list for the API for over a year now and heard little from it except that it's now being backbenched, and the rediculous price hike recently.
Wish me luck 👍
Userlevel 4
Badge
Thanks Terry, Im quiet new to Python but learning fast. Ive not ventured into NodeRED yet. When I ran the script there was issues with MySQL but the data was displayed on the screen as it should.

Trying to work out how to adapt the code to capture gas data.

To get the gas data you just replace the Meter Point Administrative Number (MPAN) with your Meter Point Reference Number (MPRN)
Userlevel 4
Badge
That reminds me. Need to sort out leaving for a better company.
Not happy with the fact I've been on the waiting list for the API for over a year now and heard little from it except that it's now being backbenched, and the rediculous price hike recently.
Wish me luck 👍

Only waiting for an API for a year? I've been waiting much longer than that!
Userlevel 4
Badge
I'm interested in making the current live usage more accessible - the page on the website is great but means physically going to look at it, so I'd like to have the current usage readily available on something such as my phone.

I think it would also be interesting to look at the historic usage on other ways such as day of the week and cross reference with freely available weather history to see if there are correlations temperature and gas usage.🆒


Our developers will love this feedback, Gary - keep it coming! Anyone else have any suggestions for how we could use your smart meter data?

Tim

I think its us customers who want to use it Tim!
Userlevel 4
Badge
There are some of us that have been on the list for quite a while and there has been no further news on access, so dont hold your breath... There are other small startup providers that are really embracing making all this 'open' to those who are capable.
Ooh, who are they? Not been happy since Ovo pulled the plug on 5 minute data, and now you can't even view current day usage on the website.
Thanks Terry, Im quiet new to Python but learning fast. Ive not ventured into NodeRED yet. When I ran the script there was issues with MySQL but the data was displayed on the screen as it should.

Trying to work out how to adapt the code to capture gas data.

To get the gas data you just replace the Meter Point Administrative Number (MPAN) with your Meter Point Reference Number (MPRN)


Thanks, will check it out
good morning,
I would like access to the API too.

Let us play with OUR data 🙂
Hi @Tim_OVO,

Is there any more news on the Live usage API access? I signed up quite a while ago now but haven't heard any news about the trial. I'm keen to build a component for the Home Assistant opensource home automation server to make it aware of energy usage within the home.

Also will the live usage API give real-time information uploaded to OVO via the supplied CAD rather than having to wait for the smart meter to check in every half and hour.

Regards,

Adrian.
Hi @Tim_OVO,

Is there any more news on the Live usage API access? I signed up quite a while ago now but haven't heard any news about the trial. I'm keen to build a component for the Home Assistant opensource home automation server to make it aware of energy usage within the home.

Also will the live usage API give real-time information uploaded to OVO via the supplied CAD rather than having to wait for the smart meter to check in every half and hour.

Regards,

Adrian.


Ive just stated to get involved in Home Assistant with Hassio on the pi. Very good system.
Userlevel 2
I really like OVO, but a 30+% price hike is just too much, when other suppliers offer better deals.

To be fair to OVO, in the spirit of full disclosure, etc, and having shopped around and built up a decent sized spreadsheet comparison of fixed tariff alternatives, I didn't find any price-fixed tariffs that was better than their 24mth Fixed Tariff online offer, so I will be staying with OVO for another 2 years.

And this has the upside that I will have one less ESP8266 project less to do, as the Python script being called from Node RED continues to do everything that I would want it to. ☺

The lack of standardisation of Smart metering during initial roll-out was a major cock-up on the part of the regulators, IMO, as the loss of Smart Metering on switch is an impediment to consumer choice.

Thanks Terry, Im quiet new to Python but learning fast. Ive not ventured into NodeRED yet. When I ran the script there was issues with MySQL but the data was displayed on the screen as it should.

Trying to work out how to adapt the code to capture gas data.
To get the gas data you just replace the Meter Point Administrative Number (MPAN) with your Meter Point Reference Number (MPRN)



Still not sure on where or how to change the MPRN number in the script if anyone can help.
Userlevel 2
@jdenver, I have a passive-class house which uses electricity only, so I haven't needed to work out how the API works for gas MPRNs.

The logon function established a new session with the OVO server and collects the valid session cookies for your account in the returned Session object. The getMPAN function issues a /api/paym/accounts request which returns a JSON object containing all of your account info.

If you use the debugger mode in FF or Chrome, then you can walk this object interactively to see the field that you need to pick. I infer from what @SianiAnni says, that there is a corresponding mprn field that you could access in line 67 as data[0]['consumers'][0]['mprm'] to fetch your MPRN, and that this can be substituted in the remaining code to get your gas half-hourly figures. (Perhaps she could clarify.)

As I said, I don't have a gas meter so I can't check this myself.

Hope this helps ☺
Userlevel 6
Badge
Hi everyone on this thread!

I've had an update from the team about the Smart live usage API - unfortunately we're no longer running trials at the moment, but if anyone is still interested, send us your details and we can add you to our list of future volunteers.

Thanks

Reply