Solved

Can we get access to the live usage API?



Show first post

204 replies

Hi All,

I have just written a PowerShell script to fetch all of my readings from January 2017 to present-day a month at a time.

You can find it on GitHub at

https://github.com/MikeWilliams-UK/Bulk-Fetch-Ovo-Readings

Have fun

@Tim_OVO Given that some of Ovo’s customers have been asking for this and more for many years, I think @Jequinlan deserves a big round of applause for sharing his code. I agree that without the backing of Ovo, it should be used with a degree of caution. It could just stop working one day, when Ovo next change their api? interface, as happened in the Hive community recently. 

Yes, if the api changes it could stop, but also the apis are soft coded in the config file so if a trivial change the config will just need updating. The risk of any 3rd party integration exists if any 1st party changes an apinin any situation.

 

If ovo want to see the code , then i am happy to discuss.

Warning: This only protects the user if the API end-point changes, not when the format of data it fetches changes.

If I add my username and password into the settings json file I get

 

OvoData.exe -f 01/01/2020 -t 04/02/2020 -o .\OvoData.csv
Unable to login - 401 - Unauthorized
   at OvoData.OvoLiveRepository.OvoConnect.GetLoginCookieAsync(String userName, String password)
   at OvoData.OvoOrchestrator.ExportData()
   at OvoData.Program.EntryPoint.Run()

Oh! Erm, please just use commandline then  no idea why that didnt work! (You kept the "" right?)

Yep, I kept the quotes to make sure it’s still valid json string.

Btw, I can confirm there is no risk of insecure as you will see from the command line the details are on your machine and provided to directly access ovo, the exe has been made by best practice .net core code and is a standalone on pc only exe.


Is the program open or closed source?

Userlevel 7
Badge +5

@Jequinlanwrote:

i will see if i can make a docker version for mac or linux users.

Linux would be great :)

Raspberry-Pi or Arduino would be better still because we can then make our own IHDs   :hugging:

Userlevel 7
Badge +2

@Tim_OVO Given that some of Ovo’s customers have been asking for this and more for many years, I think @Jequinlan deserves a big round of applause for sharing his code. I agree that without the backing of Ovo, it should be used with a degree of caution. It could just stop working one day, when Ovo next change their api? interface, as happened in the Hive community recently. 

Yes, if the api changes it could stop, but also the apis are soft coded in the config file so if a trivial change the config will just need updating. The risk of any 3rd party integration exists if any 1st party changes an apinin any situation.

 

If ovo want to see the code , then i am happy to discuss.

Userlevel 4
Badge

@Tim_OVO Given that some of Ovo’s customers have been asking for this and more for many years, I think @Jequinlan deserves a big round of applause for sharing his code. I agree that without the backing of Ovo, it should be used with a degree of caution. It could just stop working one day, when Ovo next change their api? interface, as happened in the Hive community recently. 

Userlevel 7
Badge +2

If I add my username and password into the settings json file I get

 

OvoData.exe -f 01/01/2020 -t 04/02/2020 -o .\OvoData.csv
Unable to login - 401 - Unauthorized
   at OvoData.OvoLiveRepository.OvoConnect.GetLoginCookieAsync(String userName, String password)
   at OvoData.OvoOrchestrator.ExportData()
   at OvoData.Program.EntryPoint.Run()

Oh! Erm, please just use commandline then  no idea why that didnt work! (You kept the "" right?)

Userlevel 7
Badge +2

Please confirm @Jequinlan - does this solution only work on PCs running Windoze?

Hmm, i would think so I am afraid  but i will see if i can make a docker version for mac or linux users.

If I add my username and password into the settings json file I get

 

OvoData.exe -f 01/01/2020 -t 04/02/2020 -o .\OvoData.csv
Unable to login - 401 - Unauthorized
   at OvoData.OvoLiveRepository.OvoConnect.GetLoginCookieAsync(String userName, String password)
   at OvoData.OvoOrchestrator.ExportData()
   at OvoData.Program.EntryPoint.Run()

You can put them in there to save typing them all the time! Thats all. Then you can omit those params from command line.


Ought to be in the readme (as a programmer I guessed that might be the case)

PS:

In order to save the output in the same folder as the exe I had to specify .\output.csv as the file name

Userlevel 7
Badge +5

Please confirm @Jequinlan - does this solution only work on PCs running Windoze?

Userlevel 7
Badge +2

You can put them in there to save typing them all the time! Thats all. Then you can omit those params from command line.

Thanks this is great.

What’s the purpose of the fields Login, Password and File in the appsettings.json

The command line in the readme seems to negate their existence in the settings file!

{

  "OvoUrls": {

    "Login": "https://my.ovoenergy.com/api/v2/auth/login",

    "Accounts": "https://smartpaym.ovoenergy.com/api/customer-and-account-ids",

    "Usage": "https://smartpaym.ovoenergy.com/api/energy-usage/"

  },

  "OvoAccount": {

    "Login": "x",

    "Password": "x"

  },

  "Output": {

    "File": "s:\\MyFile.csv"

  }

}

 

Userlevel 7
Badge +2

Btw, I can confirm there is no risk of insecure as you will see from the command line the details are on your machine and provided to directly access ovo, the exe has been made by best practice .net core code and is a standalone on pc only exe.

Userlevel 7
Badge +2

Thanks @Jequinlan Have got it working, and it confirms last HH gas data was logged on 19 August 23:30!

What’s the TOU comparison tool you’re working on next?

I am working on creating a "price comparison tool" for taking your actuals and comparing to tarrifs from suppliers where rates may change on up to a half hourly basis. Allowing a true "annual cost projection"

Userlevel 7

@Jequinlan I will have a read of this, but without an OVO account I won’t be able to test :pensive: Sounds like amazing customer-led action though!

 

Please be advised that from OVO’s point of view, I neither condone or condemn this workaround. It’s untested and possibly insecure, either way it’s not made alongside OVO. However I know there's been lots of interest, and (whilst OVO/Kaluza developers are tabling an idea that will be of interest to everyone here in November) so far we haven't been able to deliver anything in house. 

 

So I’m tagging everyone that's commented here to make sure you're aware of this work from @Jequinlan 

 

Let us know how it goes please! 

 

@Gary @GarethMarlow @rgphilpott @atilagiant @Deanohol @Peter_Mat @didge05 @sam_cat @jmontalvo @adec @Pramsbottom @ryck @CeeJayCee @alexbaulch @Random @maccordingley @sfgreenwood @johnk @jadam @Fordy @Steveo67 @Siggy0 @CerebralDigits @deanjames @ChrisB @jadam @DaveJenYearsley @ErTnEc @Marshcroft @jordanharper @Simonfea @obiwanzamora @AdamJ @dorinho @Ross2411 @Chrherms @MikeWilliams @blakedrayson @TerryE @VibroAxe @jdenver @maurorappa @adec @100903609 @Riscy @r3m0dul8 @MyZoe.Uk @Ajk @AlanN51 @CloudCircus @r3m0dul8 @technogeoff @resoai @Fuzzysteve @mattc @andsee @uvarvu @Transparent @g-de 

Userlevel 4
Badge

Thanks @Jequinlan Have got it working, and it confirms last HH gas data was logged on 19 August 23:30!

What’s the TOU comparison tool you’re working on next?

Userlevel 7
Badge +2

@Tim_OVO @Transparent @TerryE @andsee @SianiAnni 

 

Here is it: The API exe I promised that takes all that HH data and nicely formats it into a consumable Sheet

 

https://drive.google.com/drive/folders/1A7XRov0579O53T8OsIGe3wXCk09jul0F?usp=sharing

 

Download all the files, and read the Readme! (oh, and Enjoy) - now I can start work on ther TOU comparison tool!! 

 

If anyone is willing to send me their export please do!  - It will help me build the tooling.

John (at) QuinlanServices (dot) Com 

Userlevel 7

Hey coders,

 

We might have an update on this in the not too distant future, I can’t share any more just yet, but it’s being looked into.

 

More to come on this in 2020….

Userlevel 7
Badge +2

As a small update, A rival who offers TOU have published a download file for rates, so I can start the work on the comparison model!

Userlevel 7

And whilst we’re at it, let’s tag @NinjaGeek too. He might want to playing with this as well.

 

Just in case you missed this, @NinjaGeek - check out the latest in this thread and the work done by @g-de@Jequinlan, Timmo and other contributors

Userlevel 7
Badge +2

We are getting there! 

May be a bit longer but getting there with a reusable easy download:

 

Userlevel 3

For replicating this in other languages, the process seems to be as follows:

  1. Login by sending a POST request to https://my.ovoenergy.com/api/v2/auth/login with the following JSON in the body:
    {
    "username": "...",
    "password": "...",
    "rememberMe": true
    }

    From the response, save the cookies to use in all future requests.

  2. Next, send a GET request to https://smartpaym.ovoenergy.com/api/customer-and-account-ids . Be sure to save the items in the “accountIds” property (usually only one item).

 

 

The issue with caching the cookies is that authorisation cookies have a lifetime.  IIRC, it’s 31 days, so your code still needs to handle cookie expiry and do reauthentication.  You might find it simpler just to do the authentication every time or to have a separate (say weekly) process to refresh the authentication cookie.

Reply