I want to get the cheapest three hours from now to 7AM tomorrow.
I understood I need to populate earliest_start in order to make latest_end work as tomorrow's time. However, this call creates an error (at least when executed before 14:00 when there are no values for tomorrow present):
It would be great if the service calculates the best times even if no prices are available yet for tomorrow morning.
Error:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/__init__.py", line 104, in get_lowest_price_interval
return _find_extreme_price_interval(call, lambda a, b: a < b)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/__init__.py", line 126, in _find_extreme_price_interval
return coordinator.source.find_extreme_price_interval(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/SourceShell.py", line 152, in find_extreme_price_interval
result = find_extreme_price_interval(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/extreme_price_interval.py", line 79, in find_extreme_price_interval
ip = _calc_interval_price(marketdata, start_time, duration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/extreme_price_interval.py", line 24, in _calc_interval_price
if mp.end_time > stop_time:
^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'end_time'
Please check the main branch if this solves your issue. The latest_end time is now automatically trimmed to the available market data range. Therefore is shouldn't crash anymore.
I want to get the cheapest three hours from now to 7AM tomorrow.
I understood I need to populate
earliest_start
in order to makelatest_end
work as tomorrow's time. However, this call creates an error (at least when executed before 14:00 when there are no values for tomorrow present):It would be great if the service calculates the best times even if no prices are available yet for tomorrow morning.
Error: