Initial commit
This commit is contained in:
commit
284fdc1261
16 changed files with 448 additions and 0 deletions
26
NightLight.Core/ZigbeeCommands.fs
Normal file
26
NightLight.Core/ZigbeeCommands.fs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
module NightLight.ZigbeeCommands
|
||||
|
||||
open System.Text.Json.Nodes
|
||||
open NightLight.Lights
|
||||
|
||||
type ZigbeeCommand = ZigbeeCommand of Topic: string * Payload: string
|
||||
|
||||
let internal generateZigbeeCommand friendlyName targetColor targetBrightness =
|
||||
let commandObj = JsonObject()
|
||||
|
||||
match targetColor with
|
||||
| ColorByCoordinates(x, y) ->
|
||||
let colorObj = JsonObject()
|
||||
colorObj["x"] <- x
|
||||
colorObj["y"] <- y
|
||||
commandObj["color"] <- colorObj
|
||||
| ColorByTemperature t -> commandObj["color_temp"] <- t
|
||||
|
||||
commandObj["brightness"] <-
|
||||
match targetBrightness with
|
||||
| Brightness b -> b
|
||||
|
||||
let topic = $"zigbee2mqtt/{friendlyName}/set"
|
||||
let payload = commandObj.ToJsonString()
|
||||
|
||||
ZigbeeCommand(topic, payload)
|
||||
Loading…
Add table
Add a link
Reference in a new issue