Hard code the lights controlled by the remote
This commit is contained in:
parent
50c8a413a6
commit
3855439d82
5 changed files with 40 additions and 37 deletions
|
|
@ -149,12 +149,15 @@ type FakeHome with
|
|||
|
||||
member this.NonRemotelyControlledLightStates =
|
||||
this.LightStates
|
||||
|> Seq.filter (fst >> lightProps >> _.ControlledWithRemote >> (=) NonRemote)
|
||||
|> Seq.filter (fun (light, _) ->
|
||||
light = VardagsrumVagglampa
|
||||
|| light = VardagsrumGolvlampa
|
||||
|| light = BadrumTaklampa)
|
||||
|> Seq.toList
|
||||
|
||||
member this.RemotelyControlledLightStates =
|
||||
this.LightStates
|
||||
|> Seq.filter (fst >> lightProps >> _.ControlledWithRemote >> (<>) NonRemote)
|
||||
|> Seq.filter (fun (light, _) -> light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa)
|
||||
|> Seq.toList
|
||||
|
||||
member this.Label =
|
||||
|
|
|
|||
|
|
@ -9,27 +9,30 @@ type ArbitraryLight =
|
|||
type ArbitraryNonRemotelyControlledLight =
|
||||
static member Light() =
|
||||
lights
|
||||
|> Seq.filter (fun light -> (lightProps light).ControlledWithRemote.IsNonRemote)
|
||||
|> Seq.filter (fun light ->
|
||||
light = VardagsrumVagglampa
|
||||
|| light = VardagsrumGolvlampa
|
||||
|| light = BadrumTaklampa)
|
||||
|> Gen.elements
|
||||
|> Arb.fromGen
|
||||
|
||||
type ArbitraryLeftRemotelyControlledLight =
|
||||
static member Light() =
|
||||
lights
|
||||
|> Seq.filter (fun light -> (lightProps light).ControlledWithRemote.IsRemoteLeft)
|
||||
|> Seq.filter (fun light -> light = SovrumNattduksbordlampa)
|
||||
|> Gen.elements
|
||||
|> Arb.fromGen
|
||||
|
||||
type ArbitraryRightRemotelyControlledLight =
|
||||
static member Light() =
|
||||
lights
|
||||
|> Seq.filter (fun light -> (lightProps light).ControlledWithRemote.IsRemoteRight)
|
||||
|> Seq.filter (fun light -> light = VardagsrumFonsterlampa)
|
||||
|> Gen.elements
|
||||
|> Arb.fromGen
|
||||
|
||||
type ArbitraryRemotelyControlledLight =
|
||||
static member Light() =
|
||||
lights
|
||||
|> Seq.filter (fun light -> (lightProps light).ControlledWithRemote.IsNonRemote |> not)
|
||||
|> Seq.filter (fun light -> light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa)
|
||||
|> Gen.elements
|
||||
|> Arb.fromGen
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ type NightLightTests() =
|
|||
&& time <= endOfAlarm
|
||||
|
||||
let scaledForAlarm light brightness =
|
||||
if (lightProps light).ControlledWithRemote <> NonRemote && alarm then
|
||||
if (light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) && alarm then
|
||||
float brightness * ((time - startOfDay) / (endOfAlarm - startOfDay)) |> byte
|
||||
else
|
||||
brightness
|
||||
|
|
@ -108,8 +108,11 @@ type NightLightTests() =
|
|||
let allOn (ls: (Light * LightState) seq) = ls |> Seq.forall (snd >> _.IsOn)
|
||||
let allOff (ls: (Light * LightState) seq) = ls |> Seq.forall (snd >> _.IsOff)
|
||||
|
||||
let controlledBy remote ls =
|
||||
ls |> Seq.filter (fst >> lightProps >> _.ControlledWithRemote >> (=) remote)
|
||||
let controlledByLeft ls =
|
||||
ls |> Seq.filter (fun (light, _) -> light = SovrumNattduksbordlampa)
|
||||
|
||||
let controlledByRight ls =
|
||||
ls |> Seq.filter (fun (light, _) -> light = VardagsrumFonsterlampa)
|
||||
|
||||
let maybeLastRemoteInteraction = tryGetLastRemoteInteraction interactions
|
||||
|
||||
|
|
@ -123,8 +126,8 @@ type NightLightTests() =
|
|||
| Some(_, RemotePressedOnButton) -> remotelyControlledLightsWithPower |> allOn
|
||||
| Some(_, RemotePressedOffButton) -> remotelyControlledLightsWithPower |> allOff
|
||||
| Some(_, RemotePressedLeftButton) ->
|
||||
remotelyControlledLightsWithPower |> controlledBy RemoteLeft |> allOn
|
||||
&& remotelyControlledLightsWithPower |> controlledBy RemoteRight |> allOff
|
||||
remotelyControlledLightsWithPower |> controlledByLeft |> allOn
|
||||
&& remotelyControlledLightsWithPower |> controlledByRight |> allOff
|
||||
| None -> remotelyControlledLightsWithPower |> allOn
|
||||
|> Prop.collect $"last remote interaction is {maybeLastRemoteInteraction |> Option.map snd}"
|
||||
|> Prop.collect $"{remotelyControlledLightsWithPower.Length} remotely controlled light(s) with power"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue