springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
92 stars 32 forks source link

Feature request: Allow for different types of optimisation #980

Open jm8-dev opened 2 months ago

jm8-dev commented 2 months ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like As we move into the summer, predbat wants to charge my battery up cheaply (usually in the early morning), and then export as much of my solar as possible. Although this usually minimises my effective energy cost (on Octopus Agile tariffs), I would like to self-consume my solar as much as possible - for example, letting the solar panels charge up the battery in the early morning. Even if this isn't the most cost effective idea, it is likely the most 'green' energy I can use.

It would be great to have a new 'select' input or 'boolean toggles' where I could choose between the following algorithim optimisations: 1) Optimise for self-consumption of solar and battery power 2) Optimise for buying grid energy when it is 'greenest' 3) Optimise for miniming cost of energy

If these were boolean toggles for the three options, I could then pick and choose my desired 'blend' of optimisations. If it is a select input that I choose between the three, then I was thinking that self-consumption of solar would be priority but the algorithm would still buy energy when it is greenest, and cheapest, whilst keeping the battery charged for the evening (i.e. a rainy summer day).

Describe alternatives you've considered I've considered using expert mode to tune the algorithm for the above, but ideally this would be a feature of predbat that I can use to pick and choose some defaults. This would make it easier when moving from winter, into spring and summer. Please let me know if you have ideas on how I could use expert mode to achieve this though!

Additional context N/A

springfall2008 commented 2 months ago

I like the idea :)

Do you know how you can determine 'greenest' on the grid inside HA?

gcoan commented 2 months ago

You can use the octopus greenness forecast for overnight periods and a longer term trend direction image

jm8-dev commented 2 months ago

Yes I thought about using Octopus' greenness forecast - currently I'm using the National Grid's Carbon Intensity API which publishes regional half-hourly carbon intensity estimates, which could work nicely with Agile.

I've integrated into HA using this guide: https://www.speaktothegeek.co.uk/2023/05/local-uk-grid-carbon-intensity-in-home-assistant/

springfall2008 commented 2 months ago

I found this integration that might help: https://github.com/jfparis/sensor.carbon_intensity_uk

mpartington commented 2 months ago

You can use the octopus greenness forecast for overnight periods and a longer term trend direction image

Is it easy to plot this? I had a quick look at bottle cap Dave's readme and wasn't sure what to plot.

gcoan commented 2 months ago

You can use the octopus greenness forecast for overnight periods and a longer term trend direction image

Is it easy to plot this? I had a quick look at bottle cap Dave's readme and wasn't sure what to plot.

Apex chart for the greenness forecast:

type: custom:apexcharts-card
experimental:
  color_threshold: true
header:
  show: true
  title: Greenness Forecast
graph_span: 7d
span:
  start: hour
apex_config:
  chart:
    height: 135
  stroke:
    width: 4
  xaxis:
    labels:
      format: ddd
series:
  - entity: sensor.octopus_energy_a_xxxx_greenness_forecast_current_index
    name: Forecast
    show:
      in_header: false
      legend_value: false
    color_threshold:
      - value: 0
        color: red
      - value: 40
        color: orange
      - value: 80
        color: green
    data_generator: |
      return entity.attributes.forecast.slice(0, 7).map((entry) => {
      return [new Date(entry.start), entry.greenness_score];
        });
springfall2008 commented 2 months ago

The forecast part is now on main using the HA integration for national grid.

Optimisation for carbon will be added soon