ha-solcast-solar: Migration from Oziee v3.x.x fails with a log full of UnboundLocalError 'index' issues

The problem

I have just upgraded from the previous integration that is no longer supported or available, but nothing is working. All sensor values are unknown, unavailable or displaying 0. I have tried manually forcing an update, but this didn’t help. My Solcast setup is unchanged and my API key is correct. Upon checking the log, I see multiple instances of this error: cannot access local variable ‘index’ where it is not associated with a value. Appreciate your help!

What version of Solcast Integration has the issue?

4.2.7

What version of Home Assistant are you using?

2025.1.0

Diagnostics information

config_entry-solcast_solar-9ab07af5d3b0ba9b3e6787f4c2c7bf82-2.json

Logs debug/info/error output

][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:54.002 INFO (MainThread) [custom_components.solcast_solar] Action: Fetching forecast
2025-01-06 16:50:54.004 DEBUG (MainThread) [custom_components.solcast_solar.coordinator] Started task update
2025-01-06 16:50:54.005 DEBUG (MainThread) [custom_components.solcast_solar.coordinator] Checking for stale usage cache
2025-01-06 16:50:54.008 INFO (MainThread) [custom_components.solcast_solar.solcastapi] Getting forecast update for site d73d-e49e-feb0-e989
2025-01-06 16:50:54.009 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Polling API for site d73d-e49e-feb0-e989, last day 2025-01-13, 176 hours
2025-01-06 16:50:54.010 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Fetching forecast
2025-01-06 16:50:54.606 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Fetch data url https://api.solcast.com.au/rooftop_sites/d73d-e49e-feb0-e989/forecasts?format=json&api_key=******2KGtsF&hours=176
2025-01-06 16:50:54.606 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] API returned data, API counter incremented from 2 to 3
2025-01-06 16:50:54.607 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Writing API usage cache file: /config/solcast-usage.json
2025-01-06 16:50:54.624 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] HTTP session status 200/Success
2025-01-06 16:50:54.624 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task fetch_data took 0.615 seconds
2025-01-06 16:50:54.626 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] 353 records returned
2025-01-06 16:50:54.667 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task load_new_data took 0.040 seconds
2025-01-06 16:50:54.678 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task apply_dampening took 0.011 seconds
2025-01-06 16:50:55.797 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task sort_and_prune took 1.119 seconds
2025-01-06 16:50:55.797 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Forecasts dictionary length 4032 (1056 un-dampened)
2025-01-06 16:50:55.826 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task build_data took 0.027 seconds
2025-01-06 16:50:55.829 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in check_data_records(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3419, in check_data_records
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:55.832 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __spline_moments(): Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2120, in __spline_moments
    self.__build_splines(self._forecasts_moment)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2099, in __build_splines
    start, _ = self.__get_forecast_list_slice(self._data_forecasts, self.get_day_start_utc())  # Get start of day index.
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:55.835 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __spline_remaining(): Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2127, in __spline_remaining
    self.__build_splines(self._forecasts_remaining, reducing=True)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2099, in __build_splines
    start, _ = self.__get_forecast_list_slice(self._data_forecasts, self.get_day_start_utc())  # Get start of day index.
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:55.835 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Task recalculate_splines took 0.007 seconds
2025-01-06 16:50:56.087 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Saved dampened forecast cache
2025-01-06 16:50:56.114 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Saved un-dampened forecast cache
2025-01-06 16:50:56.115 INFO (MainThread) [custom_components.solcast_solar.solcastapi] Forecast update completed successfully
2025-01-06 16:50:56.117 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.121 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.123 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_max_forecast_pv_estimate(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2371, in __get_max_forecast_pv_estimate
    start_index, end_index = self.__get_forecast_list_slice(data, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.126 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'int' object is not subscriptable: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1873, in get_peak_power_day
    return 0 if result is None else round(1000 * result[forecast_confidence])
                                                 ~~~~~~^^^^^^^^^^^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

2025-01-06 16:50:56.129 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_max_forecast_pv_estimate(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2371, in __get_max_forecast_pv_estimate
    start_index, end_index = self.__get_forecast_list_slice(data, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.131 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'int' object is not subscriptable: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1895, in get_peak_time_day
    return result if result is None else result["period_start"]
                                         ~~~~~~^^^^^^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

2025-01-06 16:50:56.134 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.137 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_remaining(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2204, in __get_forecast_pv_remaining
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.141 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 479, in get_sensor_value
    return self.__get_value[key][0]["method"]()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1912, in get_forecast_remaining_today
    self.__get_forecast_pv_remaining(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        start_utc,
        ^^^^^^^^^^
    ...<2 lines>...
        forecast_confidence=forecast_confidence,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ),
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2204, in __get_forecast_pv_remaining
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.144 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.148 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_remaining(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2204, in __get_forecast_pv_remaining
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.152 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1824, in get_forecast_custom_hours
    * self.__get_forecast_pv_remaining(
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        start_utc,
        ^^^^^^^^^^
    ...<2 lines>...
        forecast_confidence=forecast_confidence,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2204, in __get_forecast_pv_remaining
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.154 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.159 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.162 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_max_forecast_pv_estimate(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2371, in __get_max_forecast_pv_estimate
    start_index, end_index = self.__get_forecast_list_slice(data, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.164 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'int' object is not subscriptable: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1873, in get_peak_power_day
    return 0 if result is None else round(1000 * result[forecast_confidence])
                                                 ~~~~~~^^^^^^^^^^^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

2025-01-06 16:50:56.166 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_max_forecast_pv_estimate(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2371, in __get_max_forecast_pv_estimate
    start_index, end_index = self.__get_forecast_list_slice(data, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.169 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'int' object is not subscriptable: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1895, in get_peak_time_day
    return result if result is None else result["period_start"]
                                         ~~~~~~^^^^^^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

2025-01-06 16:50:56.174 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.178 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.181 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.185 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.188 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.192 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.194 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.198 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.201 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_estimates(): cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2273, in __get_forecast_pv_estimates
    start_index, end_index = self.__get_forecast_list_slice(  # Get start and end indexes for the requested range.
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        data, start_utc, end_utc
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.206 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: cannot access local variable 'index' where it is not associated with a value: Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 425, in extra_state_attributes
    return self._coordinator.get_sensor_extra_attributes(self.entity_description.key)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 509, in get_sensor_extra_attributes
    else fetch["method"](fetch["value"])
         ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1724, in get_forecast_day
    start_index, end_index = self.__get_forecast_list_slice(self._data_forecasts, start_utc, end_utc)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1993, in __get_forecast_list_slice
    for test_index in range(0 if search_past else self.__calc_forecast_start_index(data), end_index):
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 3402, in __calc_forecast_start_index
    return index
           ^^^^^
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value

2025-01-06 16:50:56.208 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_moment(): 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.212 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1850, in get_power_n_minutes
    return round(1000 * self.__get_forecast_pv_moment(time_utc, site=site, forecast_confidence=forecast_confidence))
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.214 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_moment(): 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.218 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1850, in get_power_n_minutes
    return round(1000 * self.__get_forecast_pv_moment(time_utc, site=site, forecast_confidence=forecast_confidence))
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.220 ERROR (MainThread) [custom_components.solcast_solar.solcastapi] Exception in __get_forecast_pv_moment(): 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.224 ERROR (MainThread) [custom_components.solcast_solar.sensor] Unable to get sensor value: 'pv_estimate': Traceback (most recent call last):
  File "/config/custom_components/solcast_solar/sensor.py", line 465, in _handle_coordinator_update
    self._sensor_data = self._coordinator.get_sensor_value(self.entity_description.key)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/coordinator.py", line 478, in get_sensor_value
    return self.__get_value[key][0]["method"](self.__get_value[key][0].get("value", 0))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 1850, in get_power_n_minutes
    return round(1000 * self.__get_forecast_pv_moment(time_utc, site=site, forecast_confidence=forecast_confidence))
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2328, in __get_forecast_pv_moment
    result = self.__get_moment(site, forecast_confidence, (time_utc - day_start).total_seconds())
  File "/config/custom_components/solcast_solar/solcastapi.py", line 2151, in __get_moment
    return self._forecasts_moment["all" if site is None else site][
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self._use_forecast_confidence if forecast_confidence is None else forecast_confidence
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ][int(n_min / 300)]
    ^
KeyError: 'pv_estimate'

2025-01-06 16:50:56.225 WARNING (MainThread) [custom_components.solcast_solar.solcastapi] Site total kW forecast today is currently unavailable for d73d-e49e-feb0-e989
2025-01-06 16:50:56.225 DEBUG (MainThread) [custom_components.solcast_solar.coordinator] Completed task update

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 39 (3 by maintainers)

Commits related to this issue

Most upvoted comments

(Re)Works now like a charm !!! Thx a lot for this great (revival) Solcast integration

That’ll do it.

Oziee didn’t add any code for users upgrading from his v3 to v4. It was much re-write, and his attitude seemed to be along the lines of, “Don’t care. Delete everything. Re-download.” It’s no surprise that he deleted his repo with that attitude.

BJ and I don’t do that stuff.

Absolutely brilliant find. Now forget it, welcome again, and enjoy the stability of BJReplay’s new Solcast world.

Bonne année, @SeByDocKy, and welcome again!

Welcome aboard @SeByDocKy! And I’m glad I left this issue open.

The issue is that the schema of config/solcast.json is not compatible with V4. This has been addressed in an unreleased update, as V3 to V4 was never addressed by Oziee.

You could try this hack if you are “wedded” to your Solcast history. https://github.com/BJReplay/ha-solcast-solar/issues/232#issuecomment-2572517377. This is essentially what the new update does. Given V3, you only have a single rooftop site if I am correct, so it should be simple-ish.

Or just spin up an SSH/terminal session and delete the cache with rm config/solcast.json if you’re not wedded. Most folks are not. Then restart the integration.

Take a backup of that file first before deletion and share it if you can. I have a love of code “archeology” and there is no PII in this file…

I welcome you heartily, because you will not look back. This repo is very much advanced from Oziee’s V3, and also light years ahead of his V4 in terms of stability and features. Good choice.

Hit me up if this lot doesn’t help.

"Hey Google, set a reminder to turn on battery charging at 11am.\

Netzero automation!

Then I have to mess with Tesla again.

Hit me up if you need a temporary oAuth Fleet Endpoint. Mine is accessible if you need to regain control.

Here we go… I found it. 3.0.55 from 30 June 2023.

I’m sure it was Ozzie’s but I can’t remember the version number … it was old though! 😃