Add second remote

This commit is contained in:
Sven van Heugten 2026-03-15 17:31:50 +01:00
parent 48c58b610c
commit 8cde891ba2
8 changed files with 51 additions and 11 deletions

View file

@ -11,7 +11,10 @@ type BedroomControllingRemoteInteraction =
| RemotePressedOffButton
| RemotePressedLeftButton
type LivingRoomControllingRemoteAction = | RemotePressedRightButton
type LivingRoomControllingRemoteAction =
| RemotePressedRightButton
| LivingRoomRemotePressedOnButton
| LivingRoomRemotePressedOffButton
type HumanInteraction =
| LightPoweredOn of Light
@ -145,6 +148,16 @@ type FakeHome() =
Payload = @"{ ""action"": ""arrow_right_click"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| LivingRoomControllingRemoteInteraction LivingRoomRemotePressedOnButton ->
{ Topic = $"zigbee2mqtt/{livingRoomRemoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""on"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| LivingRoomControllingRemoteInteraction LivingRoomRemotePressedOffButton ->
{ Topic = $"zigbee2mqtt/{livingRoomRemoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""off"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| TimeChanged newTime -> newTime |> Event.TimeChanged |> onEventPublished.Trigger
type FakeHome with

View file

@ -40,7 +40,11 @@ let private genRemoteInteraction =
[ Gen.elements [ RemotePressedOnButton; RemotePressedOffButton; RemotePressedLeftButton ]
|> Gen.map BedroomControllingRemoteInteraction
Gen.constant (LivingRoomControllingRemoteInteraction RemotePressedRightButton) ]
Gen.elements
[ RemotePressedRightButton
LivingRoomRemotePressedOnButton
LivingRoomRemotePressedOffButton ]
|> Gen.map LivingRoomControllingRemoteInteraction ]
let private genInteraction =
Gen.frequency [ 4, genTimeChanged; 1, genHumanInteraction; 1, genRemoteInteraction ]

View file

@ -98,11 +98,16 @@ type NightLightTests() =
let livingRoomLightsToggledOn =
interactions
|> Seq.filter (function
| Interaction.LivingRoomControllingRemoteInteraction RemotePressedRightButton -> true
| _ -> false)
|> Seq.length
|> fun rightPresses -> rightPresses % 2 = 0
|> Seq.choose (function
| Interaction.LivingRoomControllingRemoteInteraction interaction -> Some interaction
| _ -> None)
|> Seq.fold
(fun state interaction ->
match interaction with
| RemotePressedRightButton -> not state
| LivingRoomRemotePressedOnButton -> true
| LivingRoomRemotePressedOffButton -> false)
true
let isExpectedOn light =
match light with