OVO Energy (UK)

Hey,

I’m getting the free OVO smart meter installed at the end of the month, are there any other UK OVO/HASS users out there? Seems like a cool way to integrate gas and electricity usage.

Hey,
I also have the OVO smart gateway up and running, but have not found a way to talk to it yet (was trying to locally connect to it rather than via the website).

You can browse to the gateway and you get a login, but looking at the manual foe the hardware it looks like a login for the energy company rather than the end user.

Would be interested to hear what anyone else gets up to with them!

I’ve found a thread on the OVO customer forum that suggests that they are going to open up the smart meter API (https://forum.ovoenergy.com/all-about-ovo-23/smart-meter-live-usage-api-58) so I’m going to do a me too and get added to the trial. I would have thought it’s unlikely you’ll get anything out of the smart meter itself.

ovo user here too.
been waiting on the list for API access for a goood 5 months now though. hopefully once im on i may be able to start creating the component :joy:

1 Like

If they have a webpage, has anyone tried scraping it?

1 Like

Someone over at the ovo forum has but hasn’t posted their code. On this post

Indicated there is a smarthings integration using scraping. I’d recommend adapting that. Also they have an api in the pipeline if you are willing to wait.

I don’t have an Ovo but will get a smart meter in my next place so will be watching this thread.

Cheers

Ahh, just looked in to the smart things integration but rather than scraping the ovo webpage it actually polls the ovo smart gateway which stopped being an option for customers a while ago so won’t be useful for anyone to adapt if they signed up in the last year or two.
Futureproofing an official component will be best to be left til the API is available then.

Sounds like there’s a private api, and they will just open this up for the public api. Perhaps you could reverse engineer the private api. I think that’s how the original TRÅDFRI component was developed.

Looks like this guy did some funky work to get to the data via the WEBsite API.

2 Likes

Yes that has all the info you need to make a component for HA

1 Like

Looks like @timmo001 has done some work already! Perhaps someone could create a custom component out of it?

I have… Don’t quote me if it works though :joy: it’s built on undocumented APIs which I have been unable to get to work with my own smart system due to ovo not upgrading our account to the smart paym system. Have had something working on another account however. Did start creating an integration but didn’t get too far

1 Like

Ive been interested in this, there is a python code I had running that worked. Not tried it recently though. https://gist.github.com/TerryE/b6cd9fe2ca0ef8d7f6c1606832e45b69

This Iv been told will work with OVO but not tried it.

1 Like

I wonder if OVO would switch meters into “pairing mode” on demand. They would probably also need to whitelist MAC address of the dongle.

OVO customers have been asking for public API for ages. Sadly all I’m getting with your code is null as a response.

I was one of those. Got a little somewhere with site scraping but in the end they made changes that stopped that.
Gave up after a year and a half and moved to Octopus. Cheaper and developer API available so I’m happy enough.

I know very little Python but I’ve managed to put together some code which fetches daily usage from OVO. Sadly there is no way to get any data for today as most of the time they are only populating half-hourly period from 00:00 till 00:30 thus we can only rely on yesterday. This makes it barely usable for statistics in HA as you can’t really backdate entity values.

import logging
import requests
from datetime import datetime, timedelta

AUTH_URL = "https://my.ovoenergy.com/api/v2/auth/login"
API_URL = "https://smartpaym.ovoenergy.com/api"

_LOGGER = logging.getLogger(__name__)


class OVOEnergy:
    """Class for OVOEnergy"""

    def __init__(self, username, password):
        """Initialize"""
        try:
            self.session = requests.session()
            response = self.session.post(
                AUTH_URL,
                json={
                    "username": username,
                    "password": password,
                    "rememberMe": True
                }
            )
            if "userId" not in response.json():
                _LOGGER.exception("Authentication failure")
                return

            response = self.session.get(
                "{}/customer-and-account-ids".format(API_URL)
            )
            json_response = response.json()
            if "accountIds" not in json_response:
                _LOGGER.exception("Unable to obtain account ID")
                return
            self.account = json_response["accountIds"][0]

        except requests.exceptions.RequestException as request_error:
            _LOGGER.exception("HTTP request error: {}".format(request_error))

    def get_daily_usage(self, date):
        """Get usage data"""
        if date is None:
            return None
        usage = {}
        try:
            response = self.session.get(
                "{}/energy-usage/daily/{}?date={}".format(API_URL, self.account, date)
            )
            if response.status_code != 200:
                _LOGGER.exception("Failed to get usage data with status code: {}".format(response.status_code))
                return
            json_response = response.json()
            for utility in ["electricity", "gas"]:
                if utility in json_response:
                    for data in json_response[utility]["data"]:
                        if date == data["interval"]["start"][:-13]:
                            usage[utility] = {
                                "consumption": data["consumption"],
                                "cost_amount": data["cost"]["amount"],
                                "cost_currency": data["cost"]["currencyUnit"]
                            }
            return usage
        except requests.exceptions.RequestException as request_error:
            _LOGGER.exception("HTTP request error: {}".format(request_error))


ovo = OVOEnergy("OVO_USERNAME", "OVO_PASSWORD")
usage = ovo.get_daily_usage((datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d"))
print(usage)

2 Likes

I now have a PR open for this API from OVO. Made some improvements to the package and created an integration

1 Like