Improve types for remote button presses in tests

This commit is contained in:
Sven van Heugten 2026-03-15 11:33:26 +01:00
parent 3913522cc3
commit 1dc1faa16a
4 changed files with 25 additions and 27 deletions

View file

@ -6,11 +6,12 @@ open NightLight.Core.Models
open FsToolkit.ErrorHandling
open FSharp.Data
type RemoteInteraction =
type BedroomControllingRemoteInteraction =
| RemotePressedOnButton
| RemotePressedOffButton
| RemotePressedLeftButton
| RemotePressedRightButton
type LivingRoomControllingRemoteAction = | RemotePressedRightButton
type HumanInteraction =
| LightPoweredOn of Light
@ -18,7 +19,8 @@ type HumanInteraction =
type Interaction =
| HumanInteraction of HumanInteraction
| RemoteInteraction of RemoteInteraction
| BedroomControllingRemoteInteraction of BedroomControllingRemoteInteraction
| LivingRoomControllingRemoteInteraction of LivingRoomControllingRemoteAction
| TimeChanged of DateTime
type Color =
@ -123,22 +125,22 @@ type FakeHome() =
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| HumanInteraction(LightPoweredOff light) -> friendlyNameToFakeLight[(lightProps light).FriendlyName].PowerOff()
| RemoteInteraction RemotePressedOnButton ->
| BedroomControllingRemoteInteraction RemotePressedOnButton ->
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""on"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| RemoteInteraction RemotePressedOffButton ->
| BedroomControllingRemoteInteraction RemotePressedOffButton ->
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""off"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| RemoteInteraction RemotePressedLeftButton ->
| BedroomControllingRemoteInteraction RemotePressedLeftButton ->
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""arrow_left_click"" }" }
|> ReceivedZigbeeEvent
|> onEventPublished.Trigger
| RemoteInteraction RemotePressedRightButton ->
| LivingRoomControllingRemoteInteraction RemotePressedRightButton ->
{ Topic = $"zigbee2mqtt/{remoteControlFriendlyName.Get}"
Payload = @"{ ""action"": ""arrow_right_click"" }" }
|> ReceivedZigbeeEvent