Make the Right button toggle the living room lights
This commit is contained in:
parent
1dc1faa16a
commit
48c58b610c
3 changed files with 17 additions and 6 deletions
|
|
@ -87,6 +87,11 @@ type internal State =
|
|||
| On
|
||||
| Off
|
||||
|
||||
member this.Invert() =
|
||||
match this with
|
||||
| On -> Off
|
||||
| Off -> On
|
||||
|
||||
type internal Brightness =
|
||||
| Brightness of int
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ let internal withStateFor (light: Light) (state: State) (oldNightLightState: Nig
|
|||
{ oldNightLightState with
|
||||
LightToManualState = Map.add light state oldNightLightState.LightToManualState }
|
||||
|
||||
let internal withInvertedStateFor (light: Light) (oldNightLightState: NightLightState) =
|
||||
oldNightLightState
|
||||
|> withStateFor light (oldNightLightState.LightToManualState[light].Invert())
|
||||
|
||||
let internal withAlarmOff (oldNightLightState: NightLightState) =
|
||||
{ oldNightLightState with
|
||||
Alarm = false }
|
||||
|
|
@ -105,8 +109,8 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
|||
|> withStateFor LeftBedroomLamp On
|
||||
| PressedRight ->
|
||||
currentState
|
||||
|> withStateFor LivingRoomWallLamp Off
|
||||
|> withStateFor LivingRoomFloorLamp Off
|
||||
|> withInvertedStateFor LivingRoomWallLamp
|
||||
|> withInvertedStateFor LivingRoomFloorLamp
|
||||
|
||||
NightLightStateMachine(Some newNightLightState),
|
||||
generateZigbeeCommandsForDifference (Some currentState) newNightLightState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue