mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-07-27 17:26:48 +00:00
fix(services): preserve service call data through coordinator data fetch
In `_handle_find_block` and `_handle_find_hours`, the local `data`
variable holding the resolved service call data was rebound to the
coordinator data dict returned by `get_entry_and_data()`. As a result,
the subsequent calls to `validate_search_params(data)`,
`apply_must_finish_by(data, ...)` and `resolve_search_range(...)` read
search-range parameters from coordinator data instead of from the
service call, silently ignoring:
- must_finish_by
- search_scope
- search_start, search_end
- search_start_time, search_end_time
- search_start_day_offset, search_end_day_offset
- search_start_offset_minutes, search_end_offset_minutes
- include_current_interval
The functions fell back to the default range ("now → end of tomorrow")
for every call that depended on these parameters.
Rename the third return value of `get_entry_and_data()` to
`coordinator_data` so the service call `data` survives, restoring
deadline and search-scope semantics. `find_cheapest_schedule.py`
already uses `data_dict` for the same purpose and was not affected.
Verified locally against v0.31.0: a call with
`must_finish_by: 2026-06-01T20:00:00+02:00` now correctly produces
`search_end: 2026-06-01T20:00:00+02:00` (was end-of-tomorrow before).
This commit is contained in:
parent
6937068a7a
commit
30febd8b67
2 changed files with 10 additions and 4 deletions
|
|
@ -267,8 +267,11 @@ async def _handle_find_block(
|
||||||
# Round up to nearest quarter-hour interval
|
# Round up to nearest quarter-hour interval
|
||||||
duration_minutes = math.ceil(duration_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
duration_minutes = math.ceil(duration_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
||||||
|
|
||||||
entry, coordinator, data = get_entry_and_data(hass, entry_id)
|
# Note: rebind to coordinator_data — `data` (the resolved service call
|
||||||
rating_lookup = build_rating_lookup(data)
|
# data) is still needed below for validate_search_params() and
|
||||||
|
# apply_must_finish_by(), which read search-range parameters from it.
|
||||||
|
entry, coordinator, coordinator_data = get_entry_and_data(hass, entry_id)
|
||||||
|
rating_lookup = build_rating_lookup(coordinator_data)
|
||||||
|
|
||||||
home_id = entry.data.get("home_id")
|
home_id = entry.data.get("home_id")
|
||||||
if not home_id:
|
if not home_id:
|
||||||
|
|
|
||||||
|
|
@ -329,8 +329,11 @@ async def _handle_find_hours(
|
||||||
total_minutes = math.ceil(total_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
total_minutes = math.ceil(total_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
||||||
min_segment_minutes = math.ceil(min_segment_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
min_segment_minutes = math.ceil(min_segment_minutes_requested / INTERVAL_MINUTES) * INTERVAL_MINUTES
|
||||||
|
|
||||||
entry, coordinator, data = get_entry_and_data(hass, entry_id)
|
# Note: rebind to coordinator_data — `data` (the resolved service call
|
||||||
rating_lookup = build_rating_lookup(data)
|
# data) is still needed below for validate_search_params() and
|
||||||
|
# apply_must_finish_by(), which read search-range parameters from it.
|
||||||
|
entry, coordinator, coordinator_data = get_entry_and_data(hass, entry_id)
|
||||||
|
rating_lookup = build_rating_lookup(coordinator_data)
|
||||||
|
|
||||||
home_id = entry.data.get("home_id")
|
home_id = entry.data.get("home_id")
|
||||||
if not home_id:
|
if not home_id:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue