fix(scene): preserve automation trigger semantics

This commit is contained in:
2026-08-28 02:17:01 +08:00
parent 2624a8e1e5
commit 076a1daf5d
4 changed files with 26 additions and 15 deletions
@@ -69,8 +69,8 @@ class SceneTriggerEvaluator {
.map { date -> LocalDateTime.of(date, time) }
.firstOrNull { candidate ->
val dayMatches = trigger.daysOfWeek.isEmpty() || candidate.dayOfWeek.value in trigger.daysOfWeek
val lateness = Duration.between(candidate, now).toMinutes()
dayMatches && lateness in 0..TIME_TRIGGER_GRACE_MINUTES
val latenessSeconds = Duration.between(candidate, now).seconds
dayMatches && latenessSeconds in 0..TIME_TRIGGER_GRACE_SECONDS
}
scheduled?.let { occurrence ->
TriggerEvaluation.Matched("${occurrence.toLocalDate()}:${trigger.timeOfDay}:${trigger.id.value}")
@@ -138,7 +138,7 @@ class SceneTriggerEvaluator {
private companion object {
const val TEMPERATURE_HYSTERESIS = 0.5
const val HUMIDITY_HYSTERESIS = 2.0
const val TIME_TRIGGER_GRACE_MINUTES = 20L
const val TIME_TRIGGER_GRACE_SECONDS = 20L * 60L
}
}