Solved

Ovo integration for Home Assistant

  • 10 February 2021
  • 11 replies
  • 147 views

Userlevel 5
Badge

I’ve recently started using Home Assistant to monitor my home. I’ve got 5 Aqara temperature and humidity sensors feeding in data via a ConBee II usb device, I’ve got a Hive integration, and I’ve got an Ovo integration. But I don’t understand what the Ovo integration is showing me. The documentation says

Sensors

This integration provides a few sensors for OVO Energy:

  • Last Electricity Reading - Last meter reading consumption in kWh.
  • Last Gas Reading - Last meter reading consumption in kWh.
  • Last Electricity Cost - Last meter reading electricity cost.
  • Last Gas Cost - Last meter reading gas cost.

But it doesn’t explain whether these are half hourly readings, or daily or something else. I’m also very suspicious of an electricity reading that’s decreased over the last 48 hours.

Has anyone on here used this Home Assistant integration, and if so what do they make of it?     

icon

Best answer by Blastoise186 11 February 2021, 00:50

Unfortunately @SianiAnni , that integration looks like it’s a community contribution, for which the source code and GitHub Repository can be found at https://github.com/timmo001/ovoenergy .

It doesn’t look like it’s anything OVO’s done in an official capacity either. If you need help with that integration specifically, it might be worth creating an Issue on that repository.

I’m not really a coding expert or a developer myself, but I’ll try to read the code overnight and see if I can figure it out. It’s only Python, so it’s not too hard for me to read it!

View original

11 replies

Userlevel 7
Badge +3

Unfortunately @SianiAnni , that integration looks like it’s a community contribution, for which the source code and GitHub Repository can be found at https://github.com/timmo001/ovoenergy .

It doesn’t look like it’s anything OVO’s done in an official capacity either. If you need help with that integration specifically, it might be worth creating an Issue on that repository.

I’m not really a coding expert or a developer myself, but I’ll try to read the code overnight and see if I can figure it out. It’s only Python, so it’s not too hard for me to read it!

Userlevel 5
Badge

Thanks for pointing me in the right direction @Blastoise186!  I can see that there was a minor change to the code just 10 days ago, although I haven’t figured out whether it’s relevant, and there is no indication in Home Assistant that there’s an update available, so will raise a query via the Home Assistant forum. They’re a helpful bunch, much like the people on here:)

Userlevel 5
Badge +2

I have home assistant and the OVO integration. In my case it shows yesterdays gas and electricity consumption in kWh and £. If you want more data I’d have a look at Hildebrand for their glow stick https://shop.glowmarkt.com/products/glow-stick which you can integrate with Home Assistant.

Userlevel 7
Badge +3

Ok, I’ve spent some time reviewing the code behind the integration, both on the Home Assistant repository itself on GitHub and the upstream repository for which it gets most of the functionality from.

Please don’t forget that I’m no coding expert however and I can’t provide any kind of support for something like this. Fortunately, it’s only Python so it’s not exactly impossible to figure out what it does.

By the looks of things, the integration appears to basically be pulling data straight from the same OVO API that MyOVO uses to show you all the data in your online account. The only significant differences are that it strips out the UI and pulls raw data directly.

On the plus side, at least it’s not technically scraping the website itself, which would be pretty load generating and fairly wasteful. The downside however, is that the way the integration works means that it does technically have full access to your online account in MyOVO. Make sure to be cautious and don’t use the integration if you’re not fully confident that you can trust the code and the developers behind it.

That’s probably about as much as I can contribute though I’m afraid. But I hope it helps either way

Userlevel 5
Badge

Ok, I’ve spent some time reviewing the code behind the integration, both on the Home Assistant repository itself on GitHub and the upstream repository for which it gets most of the functionality from.

Please don’t forget that I’m no coding expert however and I can’t provide any kind of support for something like this. Fortunately, it’s only Python so it’s not exactly impossible to figure out what it does.

By the looks of things, the integration appears to basically be pulling data straight from the same OVO API that MyOVO uses to show you all the data in your online account. The only significant differences are that it strips out the UI and pulls raw data directly.

On the plus side, at least it’s not technically scraping the website itself, which would be pretty load generating and fairly wasteful. The downside however, is that the way the integration works means that it does technically have full access to your online account in MyOVO. Make sure to be cautious and don’t use the integration if you’re not fully confident that you can trust the code and the developers behind it.

That’s probably about as much as I can contribute though I’m afraid. But I hope it helps either way

 

Thanks for delving into the code:) No doubt the same API that many of us have been asking for for years!

 

Before seeing this  I had managed to confirm that some of the kWh values match those for the daily values as shown on MyOVO.

 

But I don’t understand what triggers the integration to poll MyOVO. There seem to be three data points for gas yesterday (12th), the first and second were the same gas usage for the 11th as shown on MyOVO, the third at 23:23  was a little higher, and the only one for today was just at 8:43 this morning and corresponding to the MyOVO value for 12th. The latest electricity value in both HA and MyOVO is for 11th - no data on either for yesterday, the 12th.  All seems a bit random...  But it will be useful to check gas usage against number of hours Hive switches boiler on. I’m not too interested in electricity usage at the moment. 

Userlevel 7
Badge +3

Digs through even more GitHub repos… :spy:

Well… Based on this file https://github.com/home-assistant/core/blob/dev/homeassistant/components/ovo_energy/sensor.py I found a clue or two. Line 14 in particular seems to be relevant.

If I’m understanding it all correctly, it appears to trigger using a timer based schedule that fires up the polling roughly every five minutes. Personally, I’d say that’s a little bit too aggressive for my liking, especially if the data isn’t changing that often and polling the API 288 times a day per account is an awful lot of requests smashing the server to pieces! But it is what it is I guess...

If I had access to the server logs, I could probably look through those and identify activity from this stuff fairly easily which would make it a piece of cake to figure out the polling frequency. Alas, that’s also something I can’t do as a volunteer! :wink:

Userlevel 7
Badge +3

Bit of bad news I’m afraid.

Thanks for delving into the code:) No doubt the same API that many of us have been asking for for years!

 

Unfortunately, I’m not sure that’s what this particular API is intended for and I get the feeling it’s intended for internal use only within MyOVO right now. If it was designed to be opened up, I would expect to see things like API Keys, permission scopes and possibly OAuth2 to ensure security while still allowing third-party apps to have access to just the stuff they need.

However, this doesn’t seem to be the case right now. The API just seems to be used for connecting the back end systems to MyOVO via a secure setup.

I actually happen to know of someone who could potentially stop by and leave his thoughts on this topic - who happens to be following me on the forums as well! Unfortunately however, he’s a bit shy and doesn’t like to reveal himself. You won’t be able to guess who he is however, my followers list is private and only myself and the Mods can see it. :wink:

Userlevel 5
Badge

I can’t see where the 5 minute constant is used. But I completely agree that for daily readings it doesn’t need to be that often. 

Userlevel 7
Badge +3

Hang on…

Of course… I was looking at the wrong file! This probably shows you why I’m not an expert here! Lines 70 to 77 in this other file are relevant: https://github.com/home-assistant/core/blob/dev/homeassistant/components/ovo_energy/__init__.py

But once again, seems to confirm a polling interval of every five minutes… It might as well be a WebSocket if it’s going to be that frequent! :wink:

The code for the integration itself does appear to be capable of doing half-hourly mode, but it appears to be disabled by default. I suspect this is intended to allow it to pull down the half-hourly readings data if such data exists in MyOVO.

The problem there however, is that even the Half-Hourly readings from a smart meter don’t get uploaded every 30 minutes! The meter(s) do of course capture readings every 30 minutes on that setting, but it’s still only submitted on a daily basis, shortly after midnight. So in effect, polling the API every five minutes is only either going to do one of the following:

  • Get new data, but only if it’s the first poll after MyOVO has been refreshed with the latest meter data
  • Get the same data that’s already been polled for 50+ times that day
  • Return a server error of some kind, such as HTTP 404 Not Found or HTTP 500 Internal Server Error because you crashed it…
  • Crash something and completely break
  • Get itself rate-limited and keep slamming into HTTP 429 Too Many Requests
  • Potentially get your online account in MyOVO flagged by any anti-abuse mechanisms, which might result in you getting locked out

It’s a pretty interesting concept they’ve got there, but I definitely think it would be a lot more appropriate - and a lot more respectful to OVO - if that integration were to perhaps slow down a bit? I can’t speak officially on behalf of anyone, but I’d say reducing the polling interval to  maybe once per hour or perhaps even once every 6 or 12 hours would be worth considering. Possibly also with some other protective measures in there too, in order to help prevent all these bots from smashing up the API all at the same time?

Userlevel 5
Badge +2

I did have a look at expanding on this integration but gave up because of the limitations and reliability. I switched to Hildebrand and using their MQTT stream because it allowed so much data and manipulation of that data to create Home Assistant sensors and meters. I get ½ hour gas readings and near real time electric readings. The only thing it doesn’t support natively (but there is an easy work around) is export readings from the smart meter.

Userlevel 5
Badge

Ok, thanks @Blastoise186 and @ArundaleP for info. Looks like I should disable the Ovo integration :slight_frown:.   

Reply