diff --git a/NightLight.Core/NightLightStateMachine.fs b/NightLight.Core/NightLightStateMachine.fs index 886af19..891614c 100644 --- a/NightLight.Core/NightLightStateMachine.fs +++ b/NightLight.Core/NightLightStateMachine.fs @@ -77,11 +77,6 @@ let internal withStateFor (light: Light) (state: State) (oldNightLightState: Nig (Map.add light { oldState with State = state } oldNightLightState.LightToState |> Some) -let internal withStateForRemoteControlledLights (state: State) (oldNightLightState: NightLightState) = - lights - |> Seq.filter (fun light -> light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) - |> Seq.fold (fun acc light -> acc |> withStateFor light state) oldNightLightState - let internal withAlarmOff (oldNightLightState: NightLightState) = createOrUpdateNightLightState oldNightLightState.Time false (Some oldNightLightState.LightToState) @@ -116,16 +111,21 @@ type NightLightStateMachine private (maybeState: NightLightState option) = | ButtonPress action -> let newNightLightState = match action with - | PressedOn -> currentState |> withAlarmOff |> withStateForRemoteControlledLights On - | PressedOff -> currentState |> withAlarmOff |> withStateForRemoteControlledLights Off - | PressedLeft -> - let lightThatShouldBeOn = - lights |> Seq.find (fun light -> light = SovrumNattduksbordlampa) - + | PressedOn -> currentState |> withAlarmOff - |> withStateForRemoteControlledLights Off - |> withStateFor lightThatShouldBeOn On + |> withStateFor VardagsrumFonsterlampa On + |> withStateFor SovrumNattduksbordlampa On + | PressedOff -> + currentState + |> withAlarmOff + |> withStateFor VardagsrumFonsterlampa Off + |> withStateFor SovrumNattduksbordlampa Off + | PressedLeft -> + currentState + |> withAlarmOff + |> withStateFor VardagsrumFonsterlampa Off + |> withStateFor SovrumNattduksbordlampa On NightLightStateMachine(Some newNightLightState), generateZigbeeCommandsForDifference (Some currentState) newNightLightState