fix(scene): preserve automation trigger semantics
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user