Give every light its own type

This commit is contained in:
Sven van Heugten 2026-02-27 17:49:20 +01:00
parent dbb0389e61
commit 50c8a413a6
6 changed files with 72 additions and 50 deletions

View file

@ -46,32 +46,52 @@ type LightControl =
| RemoteRight
type Light =
| VardagsrumFonsterlampa
| VardagsrumVagglampa
| VardagsrumGolvlampa
| BadrumTaklampa
| SovrumNattduksbordlampa
type LightProps =
{ FriendlyName: DeviceFriendlyName
Room: Room
Bulb: Bulb
ControlledWithRemote: LightControl }
let lightProps light =
match light with
| VardagsrumFonsterlampa ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Fönsterlampa"
Room = Bedroom
Bulb = IkeaBulb
ControlledWithRemote = RemoteRight }
| VardagsrumVagglampa ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Vägglampa"
Room = LivingRoom
Bulb = PaulmannBulb
ControlledWithRemote = NonRemote }
| VardagsrumGolvlampa ->
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Golvlampa"
Room = LivingRoom
Bulb = PaulmannBulb
ControlledWithRemote = NonRemote }
| BadrumTaklampa ->
{ FriendlyName = DeviceFriendlyName "Badrum - Taklampa"
Room = Bathroom
Bulb = IkeaBulb
ControlledWithRemote = NonRemote }
| SovrumNattduksbordlampa ->
{ FriendlyName = DeviceFriendlyName "Sovrum - Nattduksbordlampa"
Room = Bedroom
Bulb = IkeaBulb
ControlledWithRemote = RemoteLeft }
let lights =
[ { FriendlyName = DeviceFriendlyName "Vardagsrum - Fönsterlampa"
Room = Bedroom
Bulb = IkeaBulb
ControlledWithRemote = RemoteRight }
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Vägglampa"
Room = LivingRoom
Bulb = PaulmannBulb
ControlledWithRemote = NonRemote }
{ FriendlyName = DeviceFriendlyName "Vardagsrum - Golvlampa"
Room = LivingRoom
Bulb = PaulmannBulb
ControlledWithRemote = NonRemote }
{ FriendlyName = DeviceFriendlyName "Badrum - Taklampa"
Room = Bathroom
Bulb = IkeaBulb
ControlledWithRemote = NonRemote }
{ FriendlyName = DeviceFriendlyName "Sovrum - Nattduksbordlampa"
Room = Bedroom
Bulb = IkeaBulb
ControlledWithRemote = RemoteLeft } ]
[ VardagsrumFonsterlampa
VardagsrumVagglampa
VardagsrumGolvlampa
BadrumTaklampa
SovrumNattduksbordlampa ]
let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll"