diff --git a/NightLight.Core/Configuration.fs b/NightLight.Core/Configuration.fs deleted file mode 100644 index 6658ec7..0000000 --- a/NightLight.Core/Configuration.fs +++ /dev/null @@ -1,34 +0,0 @@ -module internal NightLight.Core.Configuration - -open NightLight.Core.Moods -open NightLight.Core.Lights - -let getDesiredColorAndBrightness bulb mood = - let white = ColorByCoordinates(0.3227, 0.329) - let yellow = ColorByTemperature 454 - let red = ColorByCoordinates(0.6942, 0.2963) - - match bulb, mood with - | IkeaBulb, White -> white, Brightness 254 - | IkeaBulb, Yellow -> yellow, Brightness 210 - | IkeaBulb, Red -> red, Brightness 254 - | PaulmannBulb, White -> white, Brightness 35 - | PaulmannBulb, Yellow -> yellow, Brightness 35 - | PaulmannBulb, Red -> red, Brightness 80 - -let lights = - [ { FriendlyName = "Vardagsrum - Fönsterlampa" - Room = LivingRoom - Bulb = IkeaBulb } - { FriendlyName = "Vardagsrum - Vägglampa" - Room = LivingRoom - Bulb = PaulmannBulb } - { FriendlyName = "Vardagsrum - Golvlampa" - Room = LivingRoom - Bulb = PaulmannBulb } - { FriendlyName = "Badrum - Taklampa" - Room = Bathroom - Bulb = IkeaBulb } - { FriendlyName = "Sovrum - Nattduksbordlampa" - Room = Bedroom - Bulb = IkeaBulb } ] diff --git a/NightLight.Core/Core.fs b/NightLight.Core/Core.fs index 2b1cc3b..83cc290 100644 --- a/NightLight.Core/Core.fs +++ b/NightLight.Core/Core.fs @@ -5,8 +5,6 @@ open NightLight.Core.PartsOfDay open NightLight.Core.ZigbeeEvents open NightLight.Core.ZigbeeCommands open NightLight.Core.Moods -open NightLight.Core.Lights -open NightLight.Core.Configuration open FsToolkit.ErrorHandling let internal tryFindLight friendlyName = diff --git a/NightLight.Core/Lights.fs b/NightLight.Core/Lights.fs deleted file mode 100644 index c68d96d..0000000 --- a/NightLight.Core/Lights.fs +++ /dev/null @@ -1,18 +0,0 @@ -module internal NightLight.Core.Lights - -open NightLight.Core.Moods - -type Bulb = - | IkeaBulb - | PaulmannBulb - -type Color = - | ColorByCoordinates of float * float - | ColorByTemperature of int - -type Brightness = Brightness of int - -type Light = - { FriendlyName: string - Room: Room - Bulb: Bulb } diff --git a/NightLight.Core/Models.fs b/NightLight.Core/Models.fs index 35736b0..2fb7f54 100644 --- a/NightLight.Core/Models.fs +++ b/NightLight.Core/Models.fs @@ -20,3 +20,34 @@ type ParseZigbeeEventError = | UnknownType type ParseEventError = ParseZigbeeEventError of ParseZigbeeEventError + +type Room = + | Bathroom + | LivingRoom + | Bedroom + +type Bulb = + | IkeaBulb + | PaulmannBulb + +type Light = + { FriendlyName: string + Room: Room + Bulb: Bulb } + +let lights = + [ { FriendlyName = "Vardagsrum - Fönsterlampa" + Room = LivingRoom + Bulb = IkeaBulb } + { FriendlyName = "Vardagsrum - Vägglampa" + Room = LivingRoom + Bulb = PaulmannBulb } + { FriendlyName = "Vardagsrum - Golvlampa" + Room = LivingRoom + Bulb = PaulmannBulb } + { FriendlyName = "Badrum - Taklampa" + Room = Bathroom + Bulb = IkeaBulb } + { FriendlyName = "Sovrum - Nattduksbordlampa" + Room = Bedroom + Bulb = IkeaBulb } ] diff --git a/NightLight.Core/Moods.fs b/NightLight.Core/Moods.fs index bf24695..9f33cf3 100644 --- a/NightLight.Core/Moods.fs +++ b/NightLight.Core/Moods.fs @@ -1,20 +1,35 @@ module internal NightLight.Core.Moods open NightLight.Core.PartsOfDay +open NightLight.Core.Models type Mood = | White | Yellow | Red -type Room = - | Bathroom - | LivingRoom - | Bedroom - let getDesiredMood room partOfDay = match room, partOfDay with | Bathroom, Day -> White | LivingRoom, Day -> Yellow | Bedroom, Day -> Yellow | _, Night -> Red + +type Color = + | ColorByCoordinates of float * float + | ColorByTemperature of int + +type Brightness = Brightness of int + +let getDesiredColorAndBrightness bulb mood = + let white = ColorByCoordinates(0.3227, 0.329) + let yellow = ColorByTemperature 454 + let red = ColorByCoordinates(0.6942, 0.2963) + + match bulb, mood with + | IkeaBulb, White -> white, Brightness 254 + | IkeaBulb, Yellow -> yellow, Brightness 210 + | IkeaBulb, Red -> red, Brightness 254 + | PaulmannBulb, White -> white, Brightness 35 + | PaulmannBulb, Yellow -> yellow, Brightness 35 + | PaulmannBulb, Red -> red, Brightness 80 diff --git a/NightLight.Core/NightLight.Core.fsproj b/NightLight.Core/NightLight.Core.fsproj index aea404b..31b2b6e 100644 --- a/NightLight.Core/NightLight.Core.fsproj +++ b/NightLight.Core/NightLight.Core.fsproj @@ -9,10 +9,8 @@ - - diff --git a/NightLight.Core/ZigbeeCommands.fs b/NightLight.Core/ZigbeeCommands.fs index ef8c4c8..6df6e85 100644 --- a/NightLight.Core/ZigbeeCommands.fs +++ b/NightLight.Core/ZigbeeCommands.fs @@ -2,7 +2,7 @@ module internal NightLight.Core.ZigbeeCommands open System.Text.Json.Nodes open NightLight.Core.Models -open NightLight.Core.Lights +open NightLight.Core.Moods let generateZigbeeCommand friendlyName targetColor targetBrightness = let commandObj = JsonObject()