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

@ -4,7 +4,7 @@ open System.Text.Json.Nodes
open NightLight.Core.Models
let toZigbeeCommand light payload =
let topic = $"zigbee2mqtt/{light.FriendlyName.Get}/set"
let topic = $"zigbee2mqtt/{(lightProps light).FriendlyName.Get}/set"
{ Topic = topic; Payload = payload }
let generateStateCommand state light =
@ -15,7 +15,7 @@ let generateStateCommand state light =
| On -> "ON"
| Off -> "OFF"
if light.Bulb = IkeaBulb then
if (lightProps light).Bulb = IkeaBulb then
commandObj["transition"] <- 0
commandObj.ToJsonString() |> toZigbeeCommand light