hass.tibber_prices/custom_components/tibber_prices/services
WouterGithb db5d172fb8
fix(services): preserve service call data through coordinator data fetch (#151)
* 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).

* refactor(services): update data handling in find_cheapest_schedule service

Refactor the data retrieval process to use coordinator data instead of entry data for improved clarity and consistency.

Impact: Enhances maintainability of the service code without altering user-facing functionality.

---------

Co-authored-by: “WouterK” <kwaken.geringd0w@icloud.com”git config --global user.name “WouterK”git config --global user.email kwaken.geringd0w@icloud.com”>
Co-authored-by: Julian Pawlowski <jpawlowski@users.noreply.github.com>
2026-06-01 12:45:10 +02:00
..
charging feat(services): add plan_charging service for battery/EV scheduling 2026-04-20 21:43:41 +00:00
__init__.py feat(services): add plan_charging service for battery/EV scheduling 2026-04-20 21:43:41 +00:00
debug_clear_tomorrow.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
entity_resolver.py feat(services): allow entity IDs as service parameter values 2026-04-20 18:44:24 +00:00
find_cheapest_block.py fix(services): preserve service call data through coordinator data fetch (#151) 2026-06-01 12:45:10 +02:00
find_cheapest_hours.py fix(services): preserve service call data through coordinator data fetch (#151) 2026-06-01 12:45:10 +02:00
find_cheapest_schedule.py fix(services): preserve service call data through coordinator data fetch (#151) 2026-06-01 12:45:10 +02:00
find_most_expensive_block.py feat(services): add 5 scheduling services for price-optimized time windows 2026-04-11 18:58:27 +00:00
find_most_expensive_hours.py feat(services): add 5 scheduling services for price-optimized time windows 2026-04-11 18:58:27 +00:00
formatters.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
get_apexcharts_yaml.py feat(services): add price_source parameter to get_chartdata and get_apexcharts_yaml 2026-05-03 18:48:36 +00:00
get_chartdata.py feat(services): add price_source parameter to get_chartdata and get_apexcharts_yaml 2026-05-03 18:48:36 +00:00
get_price.py feat(services): isolate price-fetch failures and add success flag to responses 2026-05-30 14:46:23 +00:00
helpers.py feat(services): isolate price-fetch failures and add success flag to responses 2026-05-30 14:46:23 +00:00
plan_charging.py feat(services): isolate price-fetch failures and add success flag to responses 2026-05-30 14:46:23 +00:00
refresh_user_data.py feat(services): add 5 scheduling services for price-optimized time windows 2026-04-11 18:58:27 +00:00
relaxation.py feat(pricing): add relaxation logic for progressive filter loosening 2026-04-18 21:27:05 +00:00