From f6b8f4ff8807c7b20c9495552777cfd5f13601f8 Mon Sep 17 00:00:00 2001 From: Philipp Arndt <2f.mail@gmx.de> Date: Mon, 17 Jan 2022 17:02:35 +0100 Subject: [PATCH] default to mirek --- lib/api/v2/device-stubs.ts | 2 +- lib/api/v2/types/light.ts | 2 +- lib/messages/light-message.ts | 2 +- lib/messages/messages.test.ts | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api/v2/device-stubs.ts b/lib/api/v2/device-stubs.ts index f1488e87..3c2bd617 100644 --- a/lib/api/v2/device-stubs.ts +++ b/lib/api/v2/device-stubs.ts @@ -163,7 +163,7 @@ export const deviceStubs = { } }, color_temperature: { - mirek: 366, + mirek: null, mirek_schema: { mirek_maximum: 500, mirek_minimum: 153 diff --git a/lib/api/v2/types/light.ts b/lib/api/v2/types/light.ts index 44e26e52..a2a2152e 100644 --- a/lib/api/v2/types/light.ts +++ b/lib/api/v2/types/light.ts @@ -17,7 +17,7 @@ export type LightDimmingData = { /* eslint-disable camelcase */ export type LightColorTemperatureData = { - mirek: number + mirek: number | null mirek_valid: boolean mirek_schema: { mirek_maximum: number diff --git a/lib/messages/light-message.ts b/lib/messages/light-message.ts index 3bc1bfe0..cd2b7c45 100644 --- a/lib/messages/light-message.ts +++ b/lib/messages/light-message.ts @@ -24,7 +24,7 @@ export const fromLight = (light: Light) => { brightness: light.dimming?.brightness ?? 0 } - if (light.color_temperature) { + if (light.color_temperature && light.color_temperature.mirek && light.color_temperature.mirek_valid) { message.color_temp = light.color_temperature.mirek } else if (light.color) { diff --git a/lib/messages/messages.test.ts b/lib/messages/messages.test.ts index 6596fdb4..8ad96da1 100755 --- a/lib/messages/messages.test.ts +++ b/lib/messages/messages.test.ts @@ -38,7 +38,6 @@ describe("Messages", () => { x: 0.4575, y: 0.4099 }, - color_temp: 366, state: "ON" }) }) @@ -61,7 +60,6 @@ describe("Messages", () => { x: 0.1, y: 0.2 }, - color_temp: 366, state: "ON" } expect(isEffectMessage(message)).toBeFalsy()