From 16996f25afde993cf06b1d7dde0552a7748b4e06 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 28 Apr 2021 00:21:23 +0200 Subject: [PATCH] Update demo lights (#9011) --- demo/src/configs/arsaboo/entities.ts | 34 +++++++++++++--------- demo/src/configs/teachingbirds/entities.ts | 22 ++++++++++++++ src/fake_data/entity.ts | 24 +++++++++++++-- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/demo/src/configs/arsaboo/entities.ts b/demo/src/configs/arsaboo/entities.ts index 63b4909255..ea1de467f2 100644 --- a/demo/src/configs/arsaboo/entities.ts +++ b/demo/src/configs/arsaboo/entities.ts @@ -246,11 +246,15 @@ export const demoEntitiesArsaboo: DemoConfig["entities"] = (localize) => "light.living_room_lights": { entity_id: "light.living_room_lights", - state: "off", + state: "on", attributes: { min_mireds: 111, max_mireds: 400, + brightness: 175, + color_temp: 300, + supported_color_modes: ["brightness", "color_temp"], friendly_name: "Living Room Lights", + color_mode: "color_temp", supported_features: 55, }, }, @@ -263,13 +267,27 @@ export const demoEntitiesArsaboo: DemoConfig["entities"] = (localize) => }, "light.kitchen_lights": { entity_id: "light.kitchen_lights", + state: "on", + attributes: { + min_mireds: 111, + max_mireds: 400, + brightness: 200, + rgb_color: [255, 175, 96], + supported_color_modes: ["brightness", "color_temp", "rgb"], + color_mode: "rgb", + friendly_name: "Kitchen Lights", + supported_features: 55, + }, + }, + "light.lifx5": { + entity_id: "light.lifx5", state: "off", attributes: { - friendly_name: "Kitchen Lights", + supported_color_modes: ["brightness"], + friendly_name: "Garage Lights", supported_features: 1, }, }, - "sensor.plexspy": { entity_id: "sensor.plexspy", state: "0", @@ -482,16 +500,6 @@ export const demoEntitiesArsaboo: DemoConfig["entities"] = (localize) => icon: "hademo:history", }, }, - "light.lifx5": { - entity_id: "light.lifx5", - state: "on", - attributes: { - min_mireds: 111, - max_mireds: 400, - friendly_name: "Garage Lights", - supported_features: 55, - }, - }, "sensor.alok_to_home": { entity_id: "sensor.alok_to_home", state: "41", diff --git a/demo/src/configs/teachingbirds/entities.ts b/demo/src/configs/teachingbirds/entities.ts index 4b61b57a36..476eab9219 100644 --- a/demo/src/configs/teachingbirds/entities.ts +++ b/demo/src/configs/teachingbirds/entities.ts @@ -1114,6 +1114,9 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => min_mireds: 153, max_mireds: 500, brightness: 63, + color_temp: 200, + supported_color_modes: ["brightness", "color_temp", "rgb"], + color_mode: "color_temp", friendly_name: "Upstairs lights", supported_features: 63, custom_ui_state_card: "state-card-custom-ui", @@ -1125,6 +1128,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { friendly_name: "Walk in closet lights", supported_features: 41, + supported_color_modes: ["brightness", "color_temp"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:wall-sconce", }, @@ -1136,6 +1140,8 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => brightness: 254, friendly_name: "Outdoor lights", supported_features: 41, + supported_color_modes: ["brightness"], + color_mode: "brightness", custom_ui_state_card: "state-card-custom-ui", icon: "mdi:wall-sconce", }, @@ -1148,6 +1154,8 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => max_mireds: 500, brightness: 128, color_temp: 366, + supported_color_modes: ["brightness", "color_temp", "rgb"], + color_mode: "color_temp", effect_list: ["colorloop"], friendly_name: "Downstairs lights", supported_features: 63, @@ -1307,6 +1315,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { min_mireds: 153, max_mireds: 500, + supported_color_modes: ["brightness", "color_temp"], is_deconz_group: false, friendly_name: "Bedside Lamp", supported_features: 63, @@ -1320,6 +1329,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { min_mireds: 153, max_mireds: 500, + supported_color_modes: ["brightness", "color_temp"], is_deconz_group: false, friendly_name: "Floorlamp Reading Light", supported_features: 43, @@ -1335,6 +1345,8 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => max_mireds: 500, brightness: 128, color_temp: 366, + supported_color_modes: ["brightness", "color_temp", "rgb"], + color_mode: "color_temp", effect_list: ["colorloop"], is_deconz_group: false, friendly_name: "Hallway window light", @@ -1349,6 +1361,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { brightness: 77, is_deconz_group: false, + supported_color_modes: ["brightness"], friendly_name: "Isa Ceiling Light", supported_features: 41, custom_ui_state_card: "state-card-custom-ui", @@ -1363,6 +1376,8 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => max_mireds: 500, brightness: 150, color_temp: 366, + supported_color_modes: ["brightness", "color_temp"], + color_mode: "color_temp", effect_list: ["colorloop"], is_deconz_group: false, friendly_name: "Floorlamp", @@ -1377,6 +1392,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { friendly_name: "Bedroom Ceiling Light", supported_features: 41, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:ceiling-light", }, @@ -1387,6 +1403,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => attributes: { friendly_name: "Nightlight", supported_features: 17, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:lamp", }, @@ -1753,6 +1770,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => power_consumption: 2.2, friendly_name: "Upstairs Hallway Light", supported_features: 33, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:ceiling-light", }, @@ -1768,6 +1786,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => power_consumption: 0, friendly_name: "Dining Room Light", supported_features: 33, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:ceiling-light", }, @@ -1783,6 +1802,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => power_consumption: 0, friendly_name: "Living room Spotlights", supported_features: 33, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:track-light", }, @@ -1799,6 +1819,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => power_consumption: 2.5, friendly_name: "Passage Lights", supported_features: 33, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:track-light", }, @@ -1843,6 +1864,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () => power_consumption: 37.4, friendly_name: "Kitchen Lights", supported_features: 33, + supported_color_modes: ["brightness"], custom_ui_state_card: "state-card-custom-ui", icon: "mdi:track-light", }, diff --git a/src/fake_data/entity.ts b/src/fake_data/entity.ts index 78913353cb..89bdbfb5b0 100644 --- a/src/fake_data/entity.ts +++ b/src/fake_data/entity.ts @@ -81,9 +81,27 @@ class LightEntity extends Entity { if (service === "turn_on") { // eslint-disable-next-line - let { brightness, hs_color, brightness_pct } = data; - brightness = (255 * brightness_pct) / 100; - this.update("on", { ...this.attributes, brightness, hs_color }); + let { hs_color, brightness_pct, rgb_color, color_temp } = data; + const attrs = { ...this.attributes }; + if (brightness_pct) { + attrs.brightness = (255 * brightness_pct) / 100; + } else if (!attrs.brightness) { + attrs.brightness = 255; + } + if (hs_color) { + attrs.color_mode = "hs"; + attrs.hs_color = hs_color; + } + if (rgb_color) { + attrs.color_mode = "rgb"; + attrs.rgb_color = rgb_color; + } + if (color_temp) { + attrs.color_mode = "color_temp"; + attrs.color_temp = color_temp; + delete attrs.rgb_color; + } + this.update("on", attrs); } else if (service === "turn_off") { this.update("off"); } else if (service === "toggle") {