Demonstrate and fix some odd behaviour with some bulbs
This commit is contained in:
parent
10d858817d
commit
c1d9029a73
2 changed files with 12 additions and 6 deletions
|
|
@ -46,6 +46,9 @@ type FakeLight(light: Light) =
|
|||
if hasPower then
|
||||
brightness <- newBrightness
|
||||
|
||||
if light.Bulb = IkeaBulb then
|
||||
state <- true
|
||||
|
||||
member _.SetColor(newColor: Color) =
|
||||
if hasPower then
|
||||
color <- newColor
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@ let internal tryFindLight friendlyName =
|
|||
Seq.tryFind (fun light -> light.FriendlyName = friendlyName) lights
|
||||
|
||||
let internal generateZigbeeCommandsToFixLight state partOfDay light =
|
||||
seq {
|
||||
yield generateStateCommand state light
|
||||
|
||||
if state = On then
|
||||
let color, brightness =
|
||||
getDesiredMood light.Room partOfDay |> getDesiredColorAndBrightness light.Bulb
|
||||
|
||||
seq {
|
||||
generateStateCommand state light
|
||||
generateZigbeeCommand color brightness light
|
||||
yield generateZigbeeCommand color brightness light
|
||||
}
|
||||
|
||||
type NightLightStateMachine private (maybeTime: DateTime option, lightToState: Map<Light, State>) =
|
||||
|
|
@ -53,7 +55,8 @@ type NightLightStateMachine private (maybeTime: DateTime option, lightToState: M
|
|||
|> Seq.fold (fun acc key -> Map.add key desiredLightState acc) lightToState
|
||||
|
||||
NightLightStateMachine(maybeTime, newLightToState),
|
||||
remoteControlledLights |> Seq.map (generateStateCommand desiredLightState)
|
||||
remoteControlledLights
|
||||
|> Seq.collect (fun light -> generateZigbeeCommandsToFixLight desiredLightState partOfDay light)
|
||||
| TimeChanged newTime, maybePartOfDay ->
|
||||
let newState = NightLightStateMachine(Some newTime, lightToState)
|
||||
let newPartOfDay = getPartOfDay newTime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue