Update
This commit is contained in:
@@ -63,6 +63,13 @@ public sealed class LightMonitorInit : ILightMonitorInit
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsRecoveryTransition(e.Old?.State))
|
||||
{
|
||||
_logger.LogInformation("Sun state recovered from {OldState}, ignoring", e.Old?.State);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Sun went below horizon, checking if anyone is home");
|
||||
|
||||
if (_presenceService.IsAnyoneHome())
|
||||
@@ -92,6 +99,12 @@ public sealed class LightMonitorInit : ILightMonitorInit
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsRecoveryTransition(e.Old?.State))
|
||||
{
|
||||
_logger.LogInformation("Person {EntityId} state recovered from {OldState}, ignoring", personEntityId, e.Old?.State);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Person {EntityId} arrived home, checking if it is dark", personEntityId);
|
||||
_lightControlService.TurnOnLight();
|
||||
}
|
||||
@@ -102,4 +115,6 @@ public sealed class LightMonitorInit : ILightMonitorInit
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsRecoveryTransition(string? oldState) => oldState is null or LightMonitorConsts.UnavailableState or LightMonitorConsts.UnknownState;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user