netzero-labs / netzero

Netzero for Tesla: Optimize your solar/battery system
https://www.netzero.energy
17 stars 1 forks source link

FR: Ability to inject dynamic tariff via POST #11

Closed purcell-lab closed 6 months ago

purcell-lab commented 7 months ago

Great work.

I see you are adding dynamic tariffs for Octopus which is nice, but of course doesn't work for everyone.

Could I suggest an improvement to be able to inject our own pricing via your API.

For example here is my pricing for the next 24 hours in 30 minute intervals, which I could easily POST via your API, which I presume you NetZero could then process and translate in a form suitable for upload into my powerwall utility rate plan via the FleetAPI.

'load_cost_forecast': [0.49, 0.42, 0.38, 0.37, 0.34, 0.21, 0.19, 0.2, 0.2, 0.18, 0.17, 0.15, 0.14, 0.15, 0.14, 0.14, 0.15, 0.14, 0.14, 0.14, 0.15, 0.19, 0.19, 0.21, 0.38, 0.24, 0.14, 0.13, 0.13, 0.11, 0.06, 0.06, 0.06, 0.09, 0.09, 0.1, 0.11, 0.11, 0.12, 0.15, 0.16, 0.19, 0.2, 0.35, 0.55, 0.56, 0.64, 0.58, 0.57, 0.55, 0.41, 0.4, 0.38, 0.24, 0.22, 0.24, 0.24, 0.21, 0.2, 0.2, 0.2, 0.2, 0.18, 0.15, 0.17, 0.17, 0.17], 
'prod_price_forecast': [0.25, 0.19, 0.14, 0.13, 0.12, 0.12, 0.1, 0.11, 0.11, 0.09, 0.08, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.1, 0.1, 0.12, 0.27, 0.15, 0.05, 0.04, 0.04, 0.04, -0.01, -0.01, -0.01, 0.01, 0.02, 0.02, 0.04, 0.04, 0.04, 0.07, 0.08, 0.11, 0.12, 0.12, 0.3, 0.32, 0.39, 0.33, 0.32, 0.3, 0.18, 0.16, 0.15, 0.15, 0.12, 0.15, 0.14, 0.12, 0.11, 0.11, 0.1, 0.11, 0.09, 0.06, 0.08, 0.08, 0.08]
rob0101 commented 7 months ago

Mark, I implemented code that mapped 30m prices into 1 of 4 tariff rates to give to the powerwall and it wasn't a great outcome.

Only having 4 price bands where each has its own FIT proved too restrictive for 30m changes.

The TBC algorithm really struggled to do predictably sensible actions for me. The old Tesla API also had some rate limits that kicked in at the most inappropriate times.

What's needed is for Tesla to accommodate highly variable pricing with individual FITs.

zigam commented 7 months ago

@purcell-lab based on our previous conversations on TMC, I assume that's for Amber Electric? I plan on adding support for Amber soon, so if that's something you'd want to test send me a note to ziga@netzeroapp.io.

@rob0101 it's possible to configure tariffs with more than 4 price bands, Netzero is currently doing this for Octopus Energy, see Dynamic Electricity Pricing.

rob0101 commented 7 months ago

Ah, that's interesting. How frequently does Tesla allow you to update the tariff ?

purcell-lab commented 7 months ago

@rob0101 it's possible to configure tariffs with more than 4 price bands, Netzero is currently doing this for Octopus Energy, see Dynamic Electricity Pricing.

Lightbulb.

teslapy.Battery.create_tariff() allows you to create more than four BatteryTariffPeriod() and more than four BatteryTariffPeriodCost(), in fact you can specify 48 periods which can be loaded into your powerwall using battery.set_tariff().

The FleetAPI also seems to support the same tariff endpoint.

image

zigam commented 7 months ago

Ah, that's interesting. How frequently does Tesla allow you to update the tariff ?

I'm not sure what the rate limits are, but for Octopus Energy at least, the tariffs only really need to be updated a few times a day: once when next day's rates are announced, and then a few minor updates throughout the day.

I imagine it would work with Amber in a similar way, but using forecasted rates.

rob0101 commented 7 months ago

I'll have a play. 4 bands was way too much of a restriction

rob0101 commented 7 months ago

I imagine it would work with Amber in a similar way, but using forecasted rates.

The Amber forecast rates can change every 5 minutes. I played with doing it every 15 minutes max, but mostly every few hours on average.

purcell-lab commented 7 months ago

How frequently does Tesla allow you to update the tariff ?

When injecting a new tariff via the API it appears in the app immediately and there doesn't appear to be an obvious rate limit.

From previous experience the tariffs are only acted upon every 15 minutes, so there could be a delay there if you make a recent change.

The question of forcing exports with inflated prices may still be an issue for exports at peak rates, but I'll have a play over the next few days.

So far this evening it is looking reasonable.

rob0101 commented 7 months ago

I was getting rate limited over a long period, eg too many requests over a 24 hour period

I don't know if it was 24 hours or some other timeframe.

It's possible the new api has different rate limits.

zigam commented 6 months ago

Amber Electric integration is now available in the Netzero app.