Viewing: apps.yaml.backup

# ------------------------------------------------------------------
# Predbat apps.yaml - Sunsynk (kellerza integration)
# Mapped to Fraser's actual Home Assistant entities (inverter prefix: "sunsynk")
# Based on the template in batpred discussion #3624, with all entity
# names corrected to match this HA instance.
# ------------------------------------------------------------------
---
pred_bat:
  module: predbat
  class: PredBat
  template: False

  # Prefix for all entities Predbat creates in HA
  prefix: predbat

  # Reference only - entities below are hard-coded to "sunsynk"
  inverter_name: "sunsynk"

  timezone: Europe/London

  currency_symbols:
    - '£'
    - 'p'

  threads: auto
  load_filter_threshold: 30

  ha_url: 'http://10.0.20.15:8123'
  ha_key: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI1MTRhYzFkYjlhYmU0NjcxOTQyNWY2ZjJjZjI2ZGE1NiIsImlhdCI6MTc4MTcyOTE2OCwiZXhwIjoyMDk3MDg5MTY4fQ.Szco1rvyCQRREBr3eebHz7Euwzeb3fewt_ETbdfl8-8'

  # ---------------- Energy sensors (inputs, auto-summed if a list) ----------------
  load_today:
    - sensor.sunsynk_day_load_energy
  import_today:
    - sensor.sunsynk_day_grid_import
  export_today:
    - sensor.sunsynk_day_grid_export

  load_power:
    - sensor.sunsynk_load_power
  grid_power:
    - sensor.sunsynk_grid_ct_power
  grid_power_invert:
    - true
  battery_power:
    - sensor.sunsynk_battery_power   # watts
  # If the battery charge/discharge sign reads backwards in Predbat, uncomment:
  #battery_power_invert:
  #  - true

  # ---------------- Inverter control ----------------
  num_inverters: 1
  inverter_type: SK

  # **** Outputs to Sunsynk inverter ****
  # Ensure on the inverter: 'Grid charge enabled', 'Solar Export', 'Use Timer'
  charge_start_service:
    - service: select.select_option
      entity_id: "select.sunsynk_prog1_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog2_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog3_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog4_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog5_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog6_charge"
      option: "Allow Grid & Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_load_limit"
      option: "Zero Export"

  charge_stop_service:
    - service: select.select_option
      entity_id: "select.sunsynk_prog1_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog2_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog3_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog4_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog5_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog6_charge"
      option: "Allow Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_load_limit"
      option: "Zero Export"

  discharge_start_service:
    - service: select.select_option
      entity_id: "select.sunsynk_prog1_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog2_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog3_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog4_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog5_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_prog6_charge"
      option: "No Grid or Gen"
    - service: select.select_option
      entity_id: "select.sunsynk_load_limit"
      option: "Allow Export"

  timed_charge_current:
    - number.sunsynk_battery_max_charge_current      # Amps
  timed_discharge_current:
    - number.sunsynk_battery_max_discharge_current   # Amps

  soc_percent:
    - sensor.sunsynk_battery_soc

  battery_voltage:
    - 51.2   # nominal 16S LiFePO4; or map to sensor.sunsynk_battery_voltage

  battery_rate_max:
    - 5000   # max charge/discharge power in W (5kW Sunsynk ECCO)

  # CONFIRM: total usable battery capacity in kWh.
  # 1x Fogstar 314Ah @ 51.2V = ~16.0 kWh. Multiply if you have more than one pack.
  soc_max:
    - 16.0

  battery_min_soc:
    - 5   # %
  reserve:
    - 4    # %

  # Predbat writes the target SoC% to prog1 only; the HA automation below
  # copies it to prog2-6 (Predbat treats multiple charge_limit entries as
  # separate inverters, so we keep one here + automation).
  charge_limit:
    - number.sunsynk_prog1_capacity
  # **** End outputs to Sunsynk inverter ****

  balance_inverters_seconds: 0
  inverter_limit:
    - 5000   # inverter rated power in W

  # ---------------- PV forecast ----------------
  # No solar PV installed - no pv_today / pv_power / Solcast forecast needed.
  # Predbat runs as a battery + grid arbitrage system only.

  # ---------------- Cars ----------------
  # Set to 0 - you manage Tesla (Achilles) charging separately via Octopus
  # target rates / Hypervolt. Increase and add car sensors to model it in Predbat.
  num_cars: 0

  # ---------------- Energy rates ----------------
  # IMPORTANT: You have TWO Octopus electricity meters. The default regex would
  # pick the flat-rate meter (20E5165518, ~22p). Below is pinned explicitly to
  # the time-of-use import meter (current ~10.6p, off-peak enabled). Change if
  # the other meter is the one that feeds the house/battery.
  metric_octopus_import: 'sensor.octopus_energy_electricity_current_rate'
  metric_standing_charge: 'sensor.octopus_energy_electricity_current_standing_charge'
  # No Octopus export/outgoing rate sensor exists (no export tariff in the
  # integration). Add when set up, e.g.:
  #metric_octopus_export: 'sensor.octopus_energy_electricity_..._export_current_rate'

  # ---------------- Octopus Octoplus saving sessions ----------------
  octopus_saving_session: 're:(binary_sensor.octopus_energy([0-9a-z_]+|)_saving_session(s|))'
  octopus_saving_session_octopoints_per_penny: 8
  octopus_free_session: 're:(event.octopus_energy_([0-9a-z_]+|)_octoplus_free_electricity_session_events)'

  # ---------------- History / forecast windows ----------------
  days_previous:
    - 7
  days_previous_weight:
    - 1
  forecast_hours: 48
  
  futurerate_url: 'https://dataportal-api.nordpoolgroup.com/api/DayAheadPrices?date=DATE&market=N2EX_DayAhead&deliveryArea=UK&currency=GBP'
  futurerate_adjust_auto: true
  futurerate_peak_start: "16:00:00"
  futurerate_peak_end: "19:00:00"

  # ---------------- Notifications ----------------
  # Set to your mobile_app notify device, e.g. mobile_app_fraser_iphone
  #notify_devices:
  #  - mobile_app_xxxxx

  battery_scaling:
    - 1.0
  import_export_scaling: 1.0

  export_triggers:
    - name: 'large'
      minutes: 60
      energy: 1.0
    - name: 'small'
      minutes: 15
      energy: 0.25