fix(ha): stefi evening lights now turn on at 20:30 even in summer
Routine_turn_on had two triggers (sunset and 20:30) but both were gated by is_dark() which requires sun.sun == below_horizon. In summer sunset in Prague is ~21:10, so the 20:30 trigger fired uselessly while sun still above horizon, and the scene only activated at actual sunset. Drop is_dark() from routine_turn_on - both triggers should activate the scene unconditionally (sunset = already dark; 20:30 = user wants lights on by then regardless of remaining daylight). Arrival_handler and motion_shutdown keep is_dark() since context there is different (don't snap lights on/off based on presence at noon). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
eb58e9c736
commit
e39aafdbbe
|
|
@ -30,19 +30,20 @@ def is_automation_allowed():
|
|||
def is_dark():
|
||||
return state.get(SUN_ENTITY) == "below_horizon"
|
||||
|
||||
# --- LOGIC 1: ROUTINE ON (Sunset or 20:30) ---
|
||||
# --- LOGIC 1: ROUTINE ON (Sunset or 20:30, whichever is earlier) ---
|
||||
|
||||
@state_trigger(f"{SUN_ENTITY} == 'below_horizon'")
|
||||
@time_trigger("once(20:30:00)")
|
||||
def stefi_routine_turn_on():
|
||||
if not is_automation_allowed(): return
|
||||
if not is_dark(): return
|
||||
|
||||
now = datetime.now()
|
||||
if now.hour >= 23:
|
||||
return
|
||||
|
||||
log.info("Stefi Lights: Routine Evening ON.")
|
||||
# NIE wymagamy is_dark() tutaj - latem sunset jest ok. 21:00, a chcemy
|
||||
# zeby scena wlaczyla sie najpozniej o 20:30 (trigger time).
|
||||
log.info(f"Stefi Lights: Routine Evening ON (dark={is_dark()}, hour={now.hour}:{now.minute:02d}).")
|
||||
scene.turn_on(entity_id=SCENE_ON_EVENING)
|
||||
scene.turn_on(entity_id=SCENE_ON_NIGHTSTAND)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue