Hard code the lights controlled by the remote

This commit is contained in:
Sven van Heugten 2026-02-27 17:59:25 +01:00
parent 50c8a413a6
commit 3855439d82
5 changed files with 40 additions and 37 deletions

View file

@ -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"