mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +00:00
fix
This commit is contained in:
parent
dd65f0efad
commit
2ef3217518
1 changed files with 5 additions and 4 deletions
|
|
@ -345,10 +345,10 @@ def _determine_now_and_simulation(
|
||||||
is_simulated = False
|
is_simulated = False
|
||||||
if time_value:
|
if time_value:
|
||||||
if not interval_selection_merged or not interval_selection_merged[0].get("start_time"):
|
if not interval_selection_merged or not interval_selection_merged[0].get("start_time"):
|
||||||
raise ServiceValidationError(
|
# Instead of raising, return a simulated now for the requested day (structure will be empty)
|
||||||
translation_domain=DOMAIN,
|
now = dt_util.now().replace(second=0, microsecond=0)
|
||||||
translation_key="no_data_for_day",
|
is_simulated = True
|
||||||
)
|
return now, is_simulated
|
||||||
day_prefix = interval_selection_merged[0]["start_time"].split("T")[0]
|
day_prefix = interval_selection_merged[0]["start_time"].split("T")[0]
|
||||||
dt_str = f"{day_prefix}T{time_value}"
|
dt_str = f"{day_prefix}T{time_value}"
|
||||||
try:
|
try:
|
||||||
|
|
@ -370,6 +370,7 @@ def _determine_now_and_simulation(
|
||||||
now = datetime.fromisoformat(dt_str)
|
now = datetime.fromisoformat(dt_str)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
now = dt_util.now().replace(second=0, microsecond=0)
|
now = dt_util.now().replace(second=0, microsecond=0)
|
||||||
|
is_simulated = True
|
||||||
return now, is_simulated
|
return now, is_simulated
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue