Spam a bit less

This commit is contained in:
Sven van Heugten 2026-01-10 21:04:20 +01:00
parent c5088ae218
commit 2f6e46960f
2 changed files with 15 additions and 6 deletions

View file

@ -11,15 +11,19 @@ open FsToolkit.ErrorHandling
let internal tryFindLight friendlyName =
Seq.tryFind (fun light -> light.FriendlyName = friendlyName) lights
let internal generateZigbeeCommandsToFixLight state partOfDay light =
let internal generateZigbeeCommandsToFixLight state partOfDay (light: Light) =
seq {
yield generateStateCommand state light
match light.ControlledWithRemote, state with
| true, _ -> yield generateStateCommand state light
| false, On -> ()
| false, Off -> failwith $"Unexpectly trying to turn off {light}. It's not remote-controlled."
if state = On then
let color, brightness =
getDesiredMood light.Room partOfDay |> getDesiredColorAndBrightness light.Bulb
yield generateZigbeeCommand color brightness light
yield generateColorCommand light color
yield generateBrightnessCommand light brightness
}
type NightLightStateMachine private (maybeTime: DateTime option, lightToState: Map<Light, State>) =