Make the Left and Right button behave the same way
This commit is contained in:
parent
451d8b09f1
commit
5d8406d8ad
4 changed files with 8 additions and 11 deletions
|
|
@ -9,9 +9,9 @@ open FSharp.Data
|
||||||
type BedroomControllingRemoteInteraction =
|
type BedroomControllingRemoteInteraction =
|
||||||
| RemotePressedOnButton
|
| RemotePressedOnButton
|
||||||
| RemotePressedOffButton
|
| RemotePressedOffButton
|
||||||
| RemotePressedLeftButton
|
|
||||||
|
|
||||||
type LivingRoomControllingRemoteAction =
|
type LivingRoomControllingRemoteAction =
|
||||||
|
| RemotePressedLeftButton
|
||||||
| RemotePressedRightButton
|
| RemotePressedRightButton
|
||||||
| LivingRoomRemotePressedOnButton
|
| LivingRoomRemotePressedOnButton
|
||||||
| LivingRoomRemotePressedOffButton
|
| LivingRoomRemotePressedOffButton
|
||||||
|
|
@ -138,7 +138,7 @@ type FakeHome() =
|
||||||
Payload = @"{ ""action"": ""off"" }" }
|
Payload = @"{ ""action"": ""off"" }" }
|
||||||
|> ReceivedZigbeeEvent
|
|> ReceivedZigbeeEvent
|
||||||
|> onEventPublished.Trigger
|
|> onEventPublished.Trigger
|
||||||
| BedroomControllingRemoteInteraction RemotePressedLeftButton ->
|
| LivingRoomControllingRemoteInteraction RemotePressedLeftButton ->
|
||||||
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
|
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
|
||||||
Payload = @"{ ""action"": ""arrow_left_click"" }" }
|
Payload = @"{ ""action"": ""arrow_left_click"" }" }
|
||||||
|> ReceivedZigbeeEvent
|
|> ReceivedZigbeeEvent
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,12 @@ let private genHumanInteraction =
|
||||||
|
|
||||||
let private genRemoteInteraction =
|
let private genRemoteInteraction =
|
||||||
Gen.oneof
|
Gen.oneof
|
||||||
[ Gen.elements [ RemotePressedOnButton; RemotePressedOffButton; RemotePressedLeftButton ]
|
[ Gen.elements [ RemotePressedOnButton; RemotePressedOffButton ]
|
||||||
|> Gen.map BedroomControllingRemoteInteraction
|
|> Gen.map BedroomControllingRemoteInteraction
|
||||||
|
|
||||||
Gen.elements
|
Gen.elements
|
||||||
[ RemotePressedRightButton
|
[ RemotePressedLeftButton
|
||||||
|
RemotePressedRightButton
|
||||||
LivingRoomRemotePressedOnButton
|
LivingRoomRemotePressedOnButton
|
||||||
LivingRoomRemotePressedOffButton ]
|
LivingRoomRemotePressedOffButton ]
|
||||||
|> Gen.map LivingRoomControllingRemoteInteraction ]
|
|> Gen.map LivingRoomControllingRemoteInteraction ]
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ type NightLightTests() =
|
||||||
|> Seq.fold
|
|> Seq.fold
|
||||||
(fun state interaction ->
|
(fun state interaction ->
|
||||||
match interaction with
|
match interaction with
|
||||||
|
| RemotePressedLeftButton -> not state
|
||||||
| RemotePressedRightButton -> not state
|
| RemotePressedRightButton -> not state
|
||||||
| LivingRoomRemotePressedOnButton -> true
|
| LivingRoomRemotePressedOnButton -> true
|
||||||
| LivingRoomRemotePressedOffButton -> false)
|
| LivingRoomRemotePressedOffButton -> false)
|
||||||
|
|
@ -127,8 +128,7 @@ type NightLightTests() =
|
||||||
| BothOff, RemotePressedOnButton -> BothOn
|
| BothOff, RemotePressedOnButton -> BothOn
|
||||||
| BothOn, RemotePressedOnButton -> LeftOn
|
| BothOn, RemotePressedOnButton -> LeftOn
|
||||||
| LeftOn, RemotePressedOnButton -> RightOn
|
| LeftOn, RemotePressedOnButton -> RightOn
|
||||||
| RightOn, RemotePressedOnButton -> BothOn
|
| RightOn, RemotePressedOnButton -> BothOn)
|
||||||
| _, RemotePressedLeftButton -> LeftOn)
|
|
||||||
BothOn
|
BothOn
|
||||||
|
|
||||||
let isExpectedOn light =
|
let isExpectedOn light =
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,7 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
||||||
|> withAlarmOff
|
|> withAlarmOff
|
||||||
|> withStateFor RightBedroomLamp Off
|
|> withStateFor RightBedroomLamp Off
|
||||||
|> withStateFor LeftBedroomLamp Off
|
|> withStateFor LeftBedroomLamp Off
|
||||||
| PressedLeft ->
|
| PressedLeft
|
||||||
currentState
|
|
||||||
|> withAlarmOff
|
|
||||||
|> withStateFor RightBedroomLamp Off
|
|
||||||
|> withStateFor LeftBedroomLamp On
|
|
||||||
| PressedRight ->
|
| PressedRight ->
|
||||||
currentState
|
currentState
|
||||||
|> withInvertedStateFor LivingRoomWallLamp
|
|> withInvertedStateFor LivingRoomWallLamp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue