Improve lamp names

This commit is contained in:
Sven van Heugten 2026-02-27 18:20:31 +01:00
parent 4a53489003
commit 1e313ca4ab
5 changed files with 35 additions and 35 deletions

View file

@ -150,14 +150,14 @@ type FakeHome with
member this.NonRemotelyControlledLightStates = member this.NonRemotelyControlledLightStates =
this.LightStates this.LightStates
|> Seq.filter (fun (light, _) -> |> Seq.filter (fun (light, _) ->
light = VardagsrumVagglampa light = LivingRoomWallLamp
|| light = VardagsrumGolvlampa || light = LivingRoomFloorLamp
|| light = BadrumTaklampa) || light = BathroomCeilingLamp)
|> Seq.toList |> Seq.toList
member this.RemotelyControlledLightStates = member this.RemotelyControlledLightStates =
this.LightStates this.LightStates
|> Seq.filter (fun (light, _) -> light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) |> Seq.filter (fun (light, _) -> light = RightBedroomLamp || light = LeftBedroomLamp)
|> Seq.toList |> Seq.toList
member this.Label = member this.Label =

View file

@ -10,29 +10,29 @@ type ArbitraryNonRemotelyControlledLight =
static member Light() = static member Light() =
lights lights
|> Seq.filter (fun light -> |> Seq.filter (fun light ->
light = VardagsrumVagglampa light = LivingRoomWallLamp
|| light = VardagsrumGolvlampa || light = LivingRoomFloorLamp
|| light = BadrumTaklampa) || light = BathroomCeilingLamp)
|> Gen.elements |> Gen.elements
|> Arb.fromGen |> Arb.fromGen
type ArbitraryLeftRemotelyControlledLight = type ArbitraryLeftRemotelyControlledLight =
static member Light() = static member Light() =
lights lights
|> Seq.filter (fun light -> light = SovrumNattduksbordlampa) |> Seq.filter (fun light -> light = LeftBedroomLamp)
|> Gen.elements |> Gen.elements
|> Arb.fromGen |> Arb.fromGen
type ArbitraryRightRemotelyControlledLight = type ArbitraryRightRemotelyControlledLight =
static member Light() = static member Light() =
lights lights
|> Seq.filter (fun light -> light = VardagsrumFonsterlampa) |> Seq.filter (fun light -> light = RightBedroomLamp)
|> Gen.elements |> Gen.elements
|> Arb.fromGen |> Arb.fromGen
type ArbitraryRemotelyControlledLight = type ArbitraryRemotelyControlledLight =
static member Light() = static member Light() =
lights lights
|> Seq.filter (fun light -> light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) |> Seq.filter (fun light -> light = RightBedroomLamp || light = LeftBedroomLamp)
|> Gen.elements |> Gen.elements
|> Arb.fromGen |> Arb.fromGen

View file

@ -52,7 +52,7 @@ type NightLightTests() =
&& time <= endOfAlarm && time <= endOfAlarm
let scaledForAlarm light brightness = let scaledForAlarm light brightness =
if (light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) && alarm then if (light = RightBedroomLamp || light = LeftBedroomLamp) && alarm then
float brightness * ((time - startOfDay) / (endOfAlarm - startOfDay)) |> byte float brightness * ((time - startOfDay) / (endOfAlarm - startOfDay)) |> byte
else else
brightness brightness
@ -109,10 +109,10 @@ type NightLightTests() =
let allOff (ls: (Light * LightState) seq) = ls |> Seq.forall (snd >> _.IsOff) let allOff (ls: (Light * LightState) seq) = ls |> Seq.forall (snd >> _.IsOff)
let controlledByLeft ls = let controlledByLeft ls =
ls |> Seq.filter (fun (light, _) -> light = SovrumNattduksbordlampa) ls |> Seq.filter (fun (light, _) -> light = LeftBedroomLamp)
let controlledByRight ls = let controlledByRight ls =
ls |> Seq.filter (fun (light, _) -> light = VardagsrumFonsterlampa) ls |> Seq.filter (fun (light, _) -> light = RightBedroomLamp)
let maybeLastRemoteInteraction = tryGetLastRemoteInteraction interactions let maybeLastRemoteInteraction = tryGetLastRemoteInteraction interactions

View file

@ -41,11 +41,11 @@ type DeviceFriendlyName =
| DeviceFriendlyName deviceFriendlyName -> deviceFriendlyName | DeviceFriendlyName deviceFriendlyName -> deviceFriendlyName
type Light = type Light =
| VardagsrumFonsterlampa | RightBedroomLamp
| VardagsrumVagglampa | LivingRoomWallLamp
| VardagsrumGolvlampa | LivingRoomFloorLamp
| BadrumTaklampa | BathroomCeilingLamp
| SovrumNattduksbordlampa | LeftBedroomLamp
type LightProps = type LightProps =
{ FriendlyName: DeviceFriendlyName { FriendlyName: DeviceFriendlyName
@ -54,33 +54,33 @@ type LightProps =
let lightProps light = let lightProps light =
match light with match light with
| VardagsrumFonsterlampa -> | RightBedroomLamp ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Fönsterlampa" { FriendlyName = DeviceFriendlyName "Vardagsrum - Fönsterlampa"
Room = Bedroom Room = Bedroom
Bulb = IkeaBulb } Bulb = IkeaBulb }
| VardagsrumVagglampa -> | LivingRoomWallLamp ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Vägglampa" { FriendlyName = DeviceFriendlyName "Vardagsrum - Vägglampa"
Room = LivingRoom Room = LivingRoom
Bulb = PaulmannBulb } Bulb = PaulmannBulb }
| VardagsrumGolvlampa -> | LivingRoomFloorLamp ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Golvlampa" { FriendlyName = DeviceFriendlyName "Vardagsrum - Golvlampa"
Room = LivingRoom Room = LivingRoom
Bulb = PaulmannBulb } Bulb = PaulmannBulb }
| BadrumTaklampa -> | BathroomCeilingLamp ->
{ FriendlyName = DeviceFriendlyName "Badrum - Taklampa" { FriendlyName = DeviceFriendlyName "Badrum - Taklampa"
Room = Bathroom Room = Bathroom
Bulb = IkeaBulb } Bulb = IkeaBulb }
| SovrumNattduksbordlampa -> | LeftBedroomLamp ->
{ FriendlyName = DeviceFriendlyName "Sovrum - Nattduksbordlampa" { FriendlyName = DeviceFriendlyName "Sovrum - Nattduksbordlampa"
Room = Bedroom Room = Bedroom
Bulb = IkeaBulb } Bulb = IkeaBulb }
let lights = let lights =
[ VardagsrumFonsterlampa [ RightBedroomLamp
VardagsrumVagglampa LivingRoomWallLamp
VardagsrumGolvlampa LivingRoomFloorLamp
BadrumTaklampa BathroomCeilingLamp
SovrumNattduksbordlampa ] LeftBedroomLamp ]
let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll" let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll"

View file

@ -48,7 +48,7 @@ let internal createOrUpdateNightLightState
light, light,
{ Color = color { Color = color
Brightness = Brightness =
if alarm && (light = VardagsrumFonsterlampa || light = SovrumNattduksbordlampa) then if alarm && (light = RightBedroomLamp || light = LeftBedroomLamp) then
brightness.Scale(getAlarmWeight time) brightness.Scale(getAlarmWeight time)
else else
brightness brightness
@ -105,18 +105,18 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
| PressedOn -> | PressedOn ->
currentState currentState
|> withAlarmOff |> withAlarmOff
|> withStateFor VardagsrumFonsterlampa On |> withStateFor RightBedroomLamp On
|> withStateFor SovrumNattduksbordlampa On |> withStateFor LeftBedroomLamp On
| PressedOff -> | PressedOff ->
currentState currentState
|> withAlarmOff |> withAlarmOff
|> withStateFor VardagsrumFonsterlampa Off |> withStateFor RightBedroomLamp Off
|> withStateFor SovrumNattduksbordlampa Off |> withStateFor LeftBedroomLamp Off
| PressedLeft -> | PressedLeft ->
currentState currentState
|> withAlarmOff |> withAlarmOff
|> withStateFor VardagsrumFonsterlampa Off |> withStateFor RightBedroomLamp Off
|> withStateFor SovrumNattduksbordlampa On |> withStateFor LeftBedroomLamp On
NightLightStateMachine(Some newNightLightState), NightLightStateMachine(Some newNightLightState),
generateZigbeeCommandsForDifference (Some currentState) newNightLightState generateZigbeeCommandsForDifference (Some currentState) newNightLightState