Reorganize types to prepare for unit testing
This commit is contained in:
parent
5219abfb4b
commit
83b716a509
7 changed files with 52 additions and 62 deletions
|
|
@ -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 } ]
|
||||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
@ -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 } ]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -9,10 +9,8 @@
|
|||
<Compile Include="Models.fs" />
|
||||
<Compile Include="PartsOfDay.fs" />
|
||||
<Compile Include="Moods.fs" />
|
||||
<Compile Include="Lights.fs" />
|
||||
<Compile Include="ZigbeeEvents.fs" />
|
||||
<Compile Include="ZigbeeCommands.fs" />
|
||||
<Compile Include="Configuration.fs" />
|
||||
<Compile Include="Core.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue