Introduce a global remoteControlledLights value
This commit is contained in:
parent
2950b21488
commit
0d21e81b82
3 changed files with 8 additions and 14 deletions
|
|
@ -15,25 +15,18 @@ type ArbitraryNonRemotelyControlledLight =
|
||||||
|
|
||||||
type ArbitraryLeftRemotelyControlledLight =
|
type ArbitraryLeftRemotelyControlledLight =
|
||||||
static member Light() =
|
static member Light() =
|
||||||
lights
|
remoteControlledLights
|
||||||
|> 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() =
|
||||||
lights
|
remoteControlledLights
|
||||||
|> 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() =
|
||||||
lights
|
remoteControlledLights |> Gen.elements |> Arb.fromGen
|
||||||
|> Seq.filter (fun light ->
|
|
||||||
match light.ControlledWithRemote with
|
|
||||||
| RemoteLeft -> true
|
|
||||||
| RemoteRight -> true
|
|
||||||
| NonRemote -> false)
|
|
||||||
|> Gen.elements
|
|
||||||
|> Arb.fromGen
|
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,7 @@ 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"
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,6 @@ type NightLightStateMachine private (maybeTime: DateTime option, lightToState: M
|
||||||
result {
|
result {
|
||||||
let maybePartOfDay = maybeTime |> Option.map getPartOfDay
|
let maybePartOfDay = maybeTime |> Option.map getPartOfDay
|
||||||
|
|
||||||
let remoteControlledLights =
|
|
||||||
lights |> Seq.filter (not << _.ControlledWithRemote.IsNonRemote)
|
|
||||||
|
|
||||||
let updateLightStateForRemoteControlledLights desiredLightState =
|
let updateLightStateForRemoteControlledLights desiredLightState =
|
||||||
remoteControlledLights
|
remoteControlledLights
|
||||||
|> Seq.fold (fun acc key -> Map.add key desiredLightState acc) lightToState
|
|> Seq.fold (fun acc key -> Map.add key desiredLightState acc) lightToState
|
||||||
|
|
@ -61,7 +58,8 @@ type NightLightStateMachine private (maybeTime: DateTime option, lightToState: M
|
||||||
| PressedLeft ->
|
| PressedLeft ->
|
||||||
updateLightStateForRemoteControlledLights Off
|
updateLightStateForRemoteControlledLights Off
|
||||||
|> Map.add
|
|> Map.add
|
||||||
(lights |> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft))
|
(remoteControlledLights
|
||||||
|
|> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft))
|
||||||
On
|
On
|
||||||
|
|
||||||
NightLightStateMachine(maybeTime, newLightToState),
|
NightLightStateMachine(maybeTime, newLightToState),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue