Remove some ambiguity
This commit is contained in:
parent
838bbb79a3
commit
cef2a20f7a
2 changed files with 8 additions and 8 deletions
|
|
@ -7,8 +7,8 @@ open FsToolkit.ErrorHandling
|
||||||
open FSharp.Data
|
open FSharp.Data
|
||||||
|
|
||||||
type HumanInteraction =
|
type HumanInteraction =
|
||||||
| LightTurnedOn of Light
|
| LightPoweredOn of Light
|
||||||
| LightTurnedOff of Light
|
| LightPoweredOff of Light
|
||||||
|
|
||||||
type Interaction =
|
type Interaction =
|
||||||
| HumanInteraction of HumanInteraction
|
| HumanInteraction of HumanInteraction
|
||||||
|
|
@ -30,9 +30,9 @@ type FakeLight(light: Light) =
|
||||||
|
|
||||||
member _.LightWithState = light, if hasPower then On(brightness, color) else Off
|
member _.LightWithState = light, if hasPower then On(brightness, color) else Off
|
||||||
|
|
||||||
member _.TurnOn() = hasPower <- true
|
member _.PowerOn() = hasPower <- true
|
||||||
|
|
||||||
member _.TurnOff() = hasPower <- false
|
member _.PowerOff() = hasPower <- false
|
||||||
|
|
||||||
member _.SetBrightness(newBrightness: byte) =
|
member _.SetBrightness(newBrightness: byte) =
|
||||||
if hasPower then
|
if hasPower then
|
||||||
|
|
@ -91,8 +91,8 @@ type FakeHome() =
|
||||||
|
|
||||||
member _.Interact(interaction: Interaction) =
|
member _.Interact(interaction: Interaction) =
|
||||||
match interaction with
|
match interaction with
|
||||||
| HumanInteraction(LightTurnedOn light) ->
|
| HumanInteraction(LightPoweredOn light) ->
|
||||||
friendlyNameToFakeLight[light.FriendlyName].TurnOn()
|
friendlyNameToFakeLight[light.FriendlyName].PowerOn()
|
||||||
|
|
||||||
{ Topic = "zigbee2mqtt/bridge/event"
|
{ Topic = "zigbee2mqtt/bridge/event"
|
||||||
Payload =
|
Payload =
|
||||||
|
|
@ -102,7 +102,7 @@ type FakeHome() =
|
||||||
}}" }
|
}}" }
|
||||||
|> ReceivedZigbeeEvent
|
|> ReceivedZigbeeEvent
|
||||||
|> onEventPublished.Trigger
|
|> onEventPublished.Trigger
|
||||||
| HumanInteraction(LightTurnedOff light) -> friendlyNameToFakeLight[light.FriendlyName].TurnOff()
|
| HumanInteraction(LightPoweredOff light) -> friendlyNameToFakeLight[light.FriendlyName].PowerOff()
|
||||||
| TimeChanged newTime -> newTime |> Event.TimeChanged |> onEventPublished.Trigger
|
| TimeChanged newTime -> newTime |> Event.TimeChanged |> onEventPublished.Trigger
|
||||||
|
|
||||||
type FakeHome with
|
type FakeHome with
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ let private genTimeChangedInteraction =
|
||||||
let private genHumanInteraction =
|
let private genHumanInteraction =
|
||||||
Gen.elements lights
|
Gen.elements lights
|
||||||
|> Gen.bind (fun light ->
|
|> Gen.bind (fun light ->
|
||||||
[ LightTurnedOn light; LightTurnedOff light ]
|
[ LightPoweredOn light; LightPoweredOff light ]
|
||||||
|> Gen.elements
|
|> Gen.elements
|
||||||
|> Gen.map Interaction.HumanInteraction)
|
|> Gen.map Interaction.HumanInteraction)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue