MattJeanes / TeslaMateAgile

Integration to automatically fill in prices for charge data captured by TeslaMate for smart energy providers
MIT License
76 stars 9 forks source link

Feature Request: Octopus Intelligent #35

Closed dakaix closed 11 months ago

dakaix commented 1 year ago

Would love to see support added for Octopus Intelligent! Can be dealt with manually for now having a fixed charging cost - but would be better if TeslamateAgile could pull the schedule directly from the Octopus API to account for any unplanned charges.

MattJeanes commented 1 year ago

Hey, we already have an API integration with Octopus set up for Octopus Agile so this shouldn't be too difficult if they are exposing an endpoint to grab pricing data from, do you know what API calls can be made to fetch either point in time pricing data or the 24 hour schedule similar to the fixed price provider?

dakaix commented 1 year ago

Doesn't look like Octopus have updated their public REST API documentation yet, however there is already a Home Assistant module (written in Python) which queries that API. I'm using it at the moment and it works as advertised to retrieve the Intelligent charging schedule each night.

Link here: https://github.com/megakid/ha_octopus_intelligent/blob/main/custom_components/octopus_intelligent/octopus_intelligent_system.py

I don't write Python, but from what I can make out it seems to centre around the "registeredKrakenflexDevice" type. This lines up with what you see in the Octopus app, as when you're on Intelligent you get a new "Devices" tab that appears inside the app - and is where you can see the proposed charging schedule (after 5pm each evening).

This dynamic schedule is required to capture any charging windows that Octopus allocates outside of the guaranteed Intelligent off-peak window (23:30-05:30), as they are also charged at the off-peak rate.

MattJeanes commented 1 year ago

Thanks for the information

I've had a look but it seems like the data is all designed to be realtime or recent history / future and I couldn't see a way to retrieve pricing data in between two arbitrary points in time which is what TeslaMateAgile needs to work properly unfortunately.

If you are able to find one (or maybe even use the same / similar one) that you can use for Agile I'll definitely look into it, I can see this being the case that it works on any Octopus tariff if you know how to call it correctly 🙂

MattJeanes commented 12 months ago

Hey so little update, I am actually using Intelligent Octopus myself now so this has become of interest to me again!

I've contacted Octopus myself and they said there is no API similar to Agile pricing for it unfortunately. I could perhaps do some work to allow recent charges to be calculated if data is available and ignore older charges, most of the time TeslaMateAgile is only calculating charges that have just finished so it could definitely be worthwhile.

Funnily enough I'm also now using Home Assistant so that custom integration is also of interest to me - I'll check it out and see if I can work something out here 😄

duncanbarnes commented 12 months ago

This may only be if you have the Octopus Mini which reads the smart meter every 10 mins or so, but within HA I have a sensor called: sensor.electricity_[METER_SERIAL_NUMBER]_current_rate

So this sensor is a little custom to each user as it has the meter serial number in it and I've not had a chance to delve into the source code for the integration to see how its getting this data but from the graph below it is varying convincingly.

HA Octopus current rate sensor
MattJeanes commented 12 months ago

I've just had a thought that might solve this and provide a lot greater flexibility:

We could simply integrate with Home Assistant directly which can listen to say, an entity state, which will provide an easy rolling window of time / price over I believe 2 weeks by default in HA which for most use cases is plenty.

This way you can just provide the number however you like, via any integration e.g. the Intelligent Octopus one above and you could even mix it in with solar/home battery data if you have that and leave TeslaMateAgile to do what it is good at which is taking a bunch of prices and associated times and calculating your charge cost.

This for me personally would solve 2 problems I'm running into at the moment:

  1. How do I take account of Intelligent Octopus' flexible rates, especially with no API
  2. How do I integrate house solar/battery into the price equation

And means TeslaMateAgile does not need to worry about storing or keeping track of prices from a live feed which has been suggested before and would have to be how it's done for Intelligent Octopus as well.

What do you guys think about that, anything else I could do to make the experience better for you?

MattJeanes commented 11 months ago

I have now done the above and Home Assistant is now a provider with the release of v1.12.0!

I've provided an example in the readme FAQ about using Intelligent Octopus and that is my recommendation for anyone wishing to use IO with TeslaMateAgile, I am using it myself this way in fact!

I am however not planning at this time to provide native support for Intelligent Octopus due to the API not being able to respond to a date range.