This commit is contained in:
Julian Pawlowski 2025-05-20 23:35:56 +00:00
parent dd65f0efad
commit 2ef3217518

View file

@ -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