Get rid of partOfDayChanged

This commit is contained in:
Sven van Heugten 2026-01-17 16:12:16 +01:00
parent bc421bc1a7
commit b55e48ab22

View file

@ -84,11 +84,11 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
| TimeChanged newTime, maybeCurrentState -> | TimeChanged newTime, maybeCurrentState ->
let newPartOfDay = getPartOfDay newTime let newPartOfDay = getPartOfDay newTime
let partOfDayChanged = let newDayStarted =
let maybePreviousPartOfDay = let maybePreviousPartOfDay =
maybeCurrentState |> Option.map _.Time |> Option.map getPartOfDay maybeCurrentState |> Option.map _.Time |> Option.map getPartOfDay
maybePreviousPartOfDay <> Some newPartOfDay maybePreviousPartOfDay <> Some Day && newPartOfDay = Day
let newLightToState = let newLightToState =
lights lights
@ -102,11 +102,7 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|> Option.map _.LightToState[light].State |> Option.map _.LightToState[light].State
|> Option.defaultValue On |> Option.defaultValue On
let newState = let newState = if newDayStarted then On else previousState
if partOfDayChanged && newPartOfDay = Day then
On
else
previousState
light, light,
{ Color = color { Color = color