Remove the remoteControlledLights helper value
This commit is contained in:
parent
0bf13d4c6f
commit
9104fac638
3 changed files with 9 additions and 9 deletions
|
|
@ -15,18 +15,21 @@ type ArbitraryNonRemotelyControlledLight =
|
||||||
|
|
||||||
type ArbitraryLeftRemotelyControlledLight =
|
type ArbitraryLeftRemotelyControlledLight =
|
||||||
static member Light() =
|
static member Light() =
|
||||||
remoteControlledLights
|
lights
|
||||||
|> Seq.filter _.ControlledWithRemote.IsRemoteLeft
|
|> Seq.filter _.ControlledWithRemote.IsRemoteLeft
|
||||||
|> Gen.elements
|
|> Gen.elements
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
||||||
type ArbitraryRightRemotelyControlledLight =
|
type ArbitraryRightRemotelyControlledLight =
|
||||||
static member Light() =
|
static member Light() =
|
||||||
remoteControlledLights
|
lights
|
||||||
|> Seq.filter _.ControlledWithRemote.IsRemoteRight
|
|> Seq.filter _.ControlledWithRemote.IsRemoteRight
|
||||||
|> Gen.elements
|
|> Gen.elements
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
||||||
type ArbitraryRemotelyControlledLight =
|
type ArbitraryRemotelyControlledLight =
|
||||||
static member Light() =
|
static member Light() =
|
||||||
remoteControlledLights |> Gen.elements |> Arb.fromGen
|
lights
|
||||||
|
|> Seq.filter (not << _.ControlledWithRemote.IsNonRemote)
|
||||||
|
|> Gen.elements
|
||||||
|
|> Arb.fromGen
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,6 @@ let lights =
|
||||||
Bulb = IkeaBulb
|
Bulb = IkeaBulb
|
||||||
ControlledWithRemote = RemoteLeft } ]
|
ControlledWithRemote = RemoteLeft } ]
|
||||||
|
|
||||||
let remoteControlledLights =
|
|
||||||
lights |> Seq.filter (not << _.ControlledWithRemote.IsNonRemote)
|
|
||||||
|
|
||||||
let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll"
|
let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll"
|
||||||
|
|
||||||
type internal State =
|
type internal State =
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ let internal withStateFor (light: Light) (state: State) (oldNightLightState: Nig
|
||||||
LightToState = Map.add light { oldState with State = state } oldNightLightState.LightToState }
|
LightToState = Map.add light { oldState with State = state } oldNightLightState.LightToState }
|
||||||
|
|
||||||
let internal withStateForRemoteControlledLights (state: State) (oldNightLightState: NightLightState) =
|
let internal withStateForRemoteControlledLights (state: State) (oldNightLightState: NightLightState) =
|
||||||
remoteControlledLights
|
lights
|
||||||
|
|> Seq.filter (not << _.ControlledWithRemote.IsNonRemote)
|
||||||
|> Seq.fold (fun acc light -> acc |> withStateFor light state) oldNightLightState
|
|> Seq.fold (fun acc light -> acc |> withStateFor light state) oldNightLightState
|
||||||
|
|
||||||
let internal withAlarmOff (oldNightLightState: NightLightState) =
|
let internal withAlarmOff (oldNightLightState: NightLightState) =
|
||||||
|
|
@ -79,8 +80,7 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
||||||
| PressedOff -> currentState |> withStateForRemoteControlledLights Off
|
| PressedOff -> currentState |> withStateForRemoteControlledLights Off
|
||||||
| PressedLeft ->
|
| PressedLeft ->
|
||||||
let lightThatShouldBeOn =
|
let lightThatShouldBeOn =
|
||||||
remoteControlledLights
|
lights |> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft)
|
||||||
|> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft)
|
|
||||||
|
|
||||||
currentState
|
currentState
|
||||||
|> withStateForRemoteControlledLights Off
|
|> withStateForRemoteControlledLights Off
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue