Spam a bit less
This commit is contained in:
parent
c5088ae218
commit
2f6e46960f
2 changed files with 15 additions and 6 deletions
|
|
@ -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>) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue