BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
572 stars 57 forks source link

Request - Pull through Live data from Octopus Home Mini #121

Closed mark-summers closed 1 year ago

mark-summers commented 1 year ago

I believe Octopus are now allowing access to the API data for live data from the Octopus Home Mini, would this be able to pull through to Home Assistant?

BottlecapDave commented 1 year ago

Hi @mark-summers. I tried looking at the APIs again yesterday but was still unable to retrieve current data. Do you know where you saw this?

mark-summers commented 1 year ago

Hi @BottlecapDave, Iā€™m not sure if you have heard of the app Octo-Aid, but it tracks Octopus usage, he is managing to pull through the live data in the app now! DF460294-14A3-4260-9B6D-21AC9DFEAEFB

BottlecapDave commented 1 year ago

Unfortunately the app is not open source so I'm not sure what API they're using. They've possibly cracked/snooped the official app?

I've sent another message to Octopus Energy to see if they'll tell me. If not, I'll try emailing the app developer to see if they can help me out.

mark-summers commented 1 year ago

They are definitely using the API, he's pretty responsive as well so hopefully he will come back to you on it!

BottlecapDave commented 1 year ago

I just had a response from Octopus Energy

The team have informed me unfortunately not direct with Octopus, however if you want to link your Octo account to another app you can get your API key and more from your account and use it in another app.

So looks like I've have to see if the developer of the app is friendly enough to tell me their secrets. If I can find some contact information...

RobinXe commented 1 year ago

Might it be the requestConsumptionData mutation in the GraphQL API, with a suitably short and recent window?

If anyone has a Mini, and an app that is successfully querying its data, then might be worth a peek with Wireshark.

BottlecapDave commented 1 year ago

I may have found the endpoint. I'm currently testing the feature.

RobinXe commented 1 year ago

Waiting in suspense for details of the endpoint! :P

BottlecapDave commented 1 year ago

Just a quick update. I've got something up and running currently refreshing every minute. However I've seen a few instances where the API has fallen over at this rate and therefore the data doesn't quite match up the web dashboards., which isn't ideal.

I think I'm going to try and reduce the refresh rate, as the energy dashboard only supports seeing on an hourly basis, however I need to test if this has any other negative impacts (e.g. data being associated with the wrong time)

mark-summers commented 1 year ago

@BottlecapDave happy to help test anything if you need it!

BottlecapDave commented 1 year ago

I've done a beta release of what I have so far, available at https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/octopus-home-mini-beta-1. I don't think this is available via HACS so might need to be installed manually. To get the sensors to appear, you need to edit your Octopus Energy account and tick "I have a Home Mini".

I've been seeing a few API gateway issues in my testing which has caused my numbers to be slightly off when compared to Octopus Energy. I think the numbers can also be effected by how Home Assistant buckets the data (when it's consumed/read vs when it's raised) in the energy dashboard so it might appear in the wrong hour block.

RobinXe commented 1 year ago

It feels like there ought to be a way to retrieve the data, that the Home Mini posts to Kraken, at a local level? I don't have mine yet (šŸ˜ž) so have no way to experiment. Does the Home Mini expose anything locally?

I'm assuming that the data it transmits will be encrypted, so proxying the post endpoint will not easily yield anything useful. I wonder whether the MCU inside has a debug port enabled.

BottlecapDave commented 1 year ago

@RobinXe There is a debug port and it looks like someone managed to get it into Home Assistant via raspberry pi (https://twitter.com/Incanus/status/1590825709114904576) - you could probably do something similar with an ESPHome. However it doesn't look like it's an official means ;)

I guess it's not in Octopus' interest to have it supply such a thing as the majority of their customers probably don't need it? Hopefully via a software update or v2 šŸ¤ž

RobinXe commented 1 year ago

@BottlecapDave Oh nice! Good find! Thanks for that.

It looks like a nice little board in there, good to see they don't appear to have glued it together, and have included holes for standard headers!

I capitulated and have just ordered a Hildebrand Glow! šŸ˜œ

mark-summers commented 1 year ago

I've done a beta release of what I have so far, available at https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/octopus-home-mini-beta-1. I don't think this is available via HACS so might need to be installed manually. To get the sensors to appear, you need to edit your Octopus Energy account and tick "I have a Home Mini".

I've been seeing a few API gateway issues in my testing which has caused my numbers to be slightly off when compared to Octopus Energy. I think the numbers can also be effected by how Home Assistant buckets the data (when it's consumed/read vs when it's raised) in the energy dashboard so it might appear in the wrong hour block.

I have downloaded the beta and all looks to be working fine, except it's not letting me add it to the energy dashboard as it is missing a statistic, am I doing something wrong?

BottlecapDave commented 1 year ago

Hmm that is odd, as I have it on my dashboard. Has this resolved itself? What is the exact error that is being displayed on the dashboard?

mark-summers commented 1 year ago

Ahh sorry, I was expecting to select Current Demand for the dashboard, I have since selected Current Consumption and it's working correctly now!

andynash commented 1 year ago

Looking forward to trying this, but our Mini is refusing to connect properly to the meter or Octopus at the mo. If it starts working I'll test the beta, but not holding out much hope as Octopus aren't responding to the support request šŸ˜’

andynash commented 1 year ago

Does the Octopus Mini beta include the latest 5.4.1 with fixes for the Tracker changes, I assume not yet?

BottlecapDave commented 1 year ago

Just pushed https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/octopus-home-mini-beta-2 which should include the 5.4.1 fixes

Tinbum1 commented 1 year ago

I use Node-Red rather than HA, would it be possible to have the API as been unable to find it.

andynash commented 1 year ago

Looking forward to trying this, but our Mini is refusing to connect properly to the meter or Octopus at the mo. If it starts working I'll test the beta, but not holding out much hope as Octopus aren't responding to the support request šŸ˜’

Update on this for anyone in the same boat, Octopus have reached out to say they have a known Bluetooth issue and hope to roll out a fix next week so hopefully I can test this then!

My solar/battery installer visited last week and saw the mini on the counter - he was very interested on behalf of customers he has for whom smart meters can't get a signal. Not sure if it is a robust enough solution (technically, security-wise and legally for actual metering though.

Tinbum1 commented 1 year ago

I spotted this a few days ago and informed them of the problem. The app doesn't ask for Bluetooth permission when using the Android version. Set it up with an 'I' phone and it will work great.

(Edit- I think they did roll out an Android update on the 10th but that then caused other Bluetooth issues).

BottlecapDave commented 1 year ago

This has now been included in the latest release (https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v6.0.0). Please read the readme with instructions and caveats.