Skip to content

Forecast.Solar Timezone issue #2821

@RangeyRover

Description

@RangeyRover

Describe the bug
Using the forecast solar method in apps.yaml PV production time alignment does not match the local timezone or solar day for lat/long

Expected behaviour
Given this input, I expected the solar forecast to align to the local Adelaide time ACDT, which the planning portion does, but is showing PV production for nighttime hours

pred_bat:
  module: predbat
  class: PredBat

  prefix: predbat
  timezone: Australia/Adelaide
  run_every: 5

  #ha_url: "http://homeassistant"
  #ha_key: "secret_ha_key.replaceme"

  # Replace this with the total PV energy generated today from your inverter
  pv_today:
    - sensor.my_home_solar_generated

  # Currency, symbol for main currency second symbol for 1/100s e.g. $ c or £ p or e c
  currency_symbols:
    - "$"
    - "c"

  # Misc
  charge_control_immediate: False
  num_cars: 0 # I don't have an EV :(

  inverter_type: TESLA
  inverter:
    name: "Tesla Powerwall via Teslemetry"
    has_rest_api: False
    has_mqtt_api: False
    output_charge_control: "none"
    has_charge_enable_time: False
    has_discharge_enable_time: False
    has_target_soc: False
    # While the Powerwall does have a reserve SoC, we don't need to
    # leverage it for controlling charge/discharge
    has_reserve_soc: False
    charge_time_format: "S"
    charge_time_entity_is_option: False
    soc_units: "%"
    num_load_entities: 1
    time_button_press: False
    clock_time_format: "%Y-%m-%d %H:%M:%S"
    write_and_poll_sleep: 2
    has_time_window: False
    support_charge_freeze: False
    support_discharge_freeze: False
    has_idle_time: False

  # ---- Live power ----
  battery_power:
    - sensor.my_home_battery_power
  battery_power_invert:
    - False

  pv_power:
    - sensor.my_home_solar_power

  load_power:
    - sensor.my_home_load_power

  grid_power:
    - sensor.my_home_grid_power

  grid_power_invert:
    - True

  inverter_reserve_max: 80 #Anything between 80-100 will always be treated as 100

  # ---- Daily energy (kWh, cumulative today) ----
  load_today:
    - sensor.my_home_home_usage
  import_today:
    - sensor.my_home_grid_imported
  export_today:
    - sensor.my_home_grid_exported

  # ---- State of charge ----
  soc_percent:
    - sensor.my_home_percentage_charged
  soc_max:
    - "27" # ensure this matches your usable kWh

  # ---- Powerwall controls via Teslemetry (must be writable) ----
  allow_charge_from_grid:
    - switch.my_home_allow_charging_from_grid
  allow_export:
    - select.my_home_allow_export

  # ---- Solar forecast (Solcast) ----
  #pv_forecast_today: sensor.energy_production_today
  #pv_forecast_tomorrow: sensor.energy_production_tomorrow

  forecast_solar:
   - latitude: -34.0
     longitude: 138.0
     kwp: 4.3
     azimuth: 6
     declination: 23
     efficiency: 0.95
  forecast_solar_max_age: 4

  # ---- Tariff sensors (Octopus) ----
  metric_octopus_import: "re:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_current_rate)"
  metric_octopus_export: "re:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_export_current_rate)"
  metric_standing_charge: "re:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_current_standing_charge)"
  octopus_free_session: "re:(event.octopus_energy_([0-9a-z_]+|)_octoplus_free_electricity_session_events)"
  threads: auto
  forecast_hours: 48

  # --- Predbat service hooks (Tesla / Teslemetry) ---
  # These hooks are called when Predbat wants to change the current
  # state of charge/discharge. They can tie-in to other HA entities.
  #
  # Tesla PW Operation modes can be one of:
  # ['self_consumption','autonomous','backup']
  #
  # grid-charging=on, mode=backup: Powerwall will charge
  # grid-charging=off, mode=backup: Powerwall will hold
  # mode=self_consumption: Powerwall will discharge

  charge_start_service:
    - service: switch.turn_on
      entity_id: switch.my_home_allow_charging_from_grid
      repeat: True
    - service: select.select_option
      entity_id: select.my_home_operation_mode
      option: "backup"
      repeat: True

  charge_hold_service:
    - service: switch.turn_off
      entity_id: switch.my_home_allow_charging_from_grid
      repeat: True
    - service: select.select_option
      entity_id: select.my_home_operation_mode
      option: "backup"
      repeat: True

  charge_freeze_service:
    - service: switch.turn_off
      entity_id: switch.my_home_allow_charging_from_grid
      repeat: True
    - service: select.select_option
      entity_id: select.my_home_operation_mode
      option: "backup"
      repeat: True

  charge_stop_service:
    - service: switch.turn_off
      entity_id: switch.my_home_allow_charging_from_grid
    - service: select.select_option
      entity_id: select.my_home_operation_mode
      option: "self_consumption"

Predbat version

Screenshots
If applicable, add screenshots to help explain your problem. The most useful ones can be your battery chart, the Predbat HTML plan and your current settings in HA.

Image

Log file
predbat.log

Predbat debug yaml file

predbat_debug.yaml

Metadata

Metadata

Labels

bugSomething isn't workingfixed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions