This was NightLightStateMachine's purpose, but it fits equally well in the actual production code.
51 lines
1.1 KiB
FSharp
51 lines
1.1 KiB
FSharp
module NightLight.Core.Models
|
|
|
|
open System
|
|
|
|
type Message = { Topic: string; Payload: string }
|
|
|
|
type Event =
|
|
| ReceivedZigbeeEvent of Message
|
|
| TimeChanged of DateTime
|
|
|
|
type ParseZigbeeEventError =
|
|
| InvalidJson
|
|
| MissingTypeField
|
|
| MissingDataField
|
|
| MissingFriendlyNameField
|
|
| InvalidTypeField
|
|
| InvalidFriendlyNameField
|
|
| 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 } ]
|