From a88b04575d5cf01adf6c0df3b7f6b598f2cabcf0 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Nov 2019 08:52:39 +0100 Subject: [PATCH 1/4] Add cover attributes to scene editor --- src/data/scene.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/data/scene.ts b/src/data/scene.ts index 26ac84014471..c878c7cbee44 100644 --- a/src/data/scene.ts +++ b/src/data/scene.ts @@ -19,6 +19,18 @@ export const SCENE_IGNORED_DOMAINS = [ ]; export const SCENE_SAVED_ATTRIBUTES = { + cover: ["current_position", "current_tilt_position"], + climate: [ + "target_temperature", + "target_temperature_high", + "target_temperature_low", + "target_humidity", + "fan_mode", + "swing_mode", + "hvac_mode", + "preset_mode", + ], + fan: ["speed", "current_direction"], light: [ "brightness", "color_temp", @@ -35,18 +47,7 @@ export const SCENE_SAVED_ATTRIBUTES = { "media_content_id", "media_content_type", ], - climate: [ - "target_temperature", - "target_temperature_high", - "target_temperature_low", - "target_humidity", - "fan_mode", - "swing_mode", - "hvac_mode", - "preset_mode", - ], vacuum: ["cleaning_mode"], - fan: ["speed", "current_direction"], water_heather: ["temperature", "operation_mode"], }; From 2f61a2f7f85477c40c5057c95330a0b02782e2a1 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Nov 2019 09:19:26 +0100 Subject: [PATCH 2/4] Add more --- src/data/scene.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/data/scene.ts b/src/data/scene.ts index c878c7cbee44..c017e4eba838 100644 --- a/src/data/scene.ts +++ b/src/data/scene.ts @@ -19,7 +19,13 @@ export const SCENE_IGNORED_DOMAINS = [ ]; export const SCENE_SAVED_ATTRIBUTES = { - cover: ["current_position", "current_tilt_position"], + counter: ["initial", "maximum", "minimum", "step"], + cover: [ + "current_position", + "current_tilt_position", + "position", + "tilt_position", + ], climate: [ "target_temperature", "target_temperature_high", @@ -30,7 +36,9 @@ export const SCENE_SAVED_ATTRIBUTES = { "hvac_mode", "preset_mode", ], - fan: ["speed", "current_direction"], + fan: ["speed", "current_direction", "oscillating"], + input_datetime: ["has_date", "has_time"], + input_select: ["option", "options"], light: [ "brightness", "color_temp", @@ -47,8 +55,9 @@ export const SCENE_SAVED_ATTRIBUTES = { "media_content_id", "media_content_type", ], - vacuum: ["cleaning_mode"], - water_heather: ["temperature", "operation_mode"], + timer: ["duration"], + vacuum: ["cleaning_mode", "fan_speed"], + water_heather: ["temperature", "operation_mode", "away_mode"], }; export interface SceneEntity extends HassEntityBase { From 72e9245da208658ae9f2aacba68b4a9db0558c92 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Nov 2019 09:47:54 +0100 Subject: [PATCH 3/4] Remove filtering of attributes --- src/data/scene.ts | 42 ---------------------- src/panels/config/scene/ha-scene-editor.ts | 13 ++----- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/src/data/scene.ts b/src/data/scene.ts index c017e4eba838..177b8dfbd8af 100644 --- a/src/data/scene.ts +++ b/src/data/scene.ts @@ -18,48 +18,6 @@ export const SCENE_IGNORED_DOMAINS = [ "zone", ]; -export const SCENE_SAVED_ATTRIBUTES = { - counter: ["initial", "maximum", "minimum", "step"], - cover: [ - "current_position", - "current_tilt_position", - "position", - "tilt_position", - ], - climate: [ - "target_temperature", - "target_temperature_high", - "target_temperature_low", - "target_humidity", - "fan_mode", - "swing_mode", - "hvac_mode", - "preset_mode", - ], - fan: ["speed", "current_direction", "oscillating"], - input_datetime: ["has_date", "has_time"], - input_select: ["option", "options"], - light: [ - "brightness", - "color_temp", - "effect", - "rgb_color", - "xy_color", - "hs_color", - ], - media_player: [ - "is_volume_muted", - "volume_level", - "sound_mode", - "source", - "media_content_id", - "media_content_type", - ], - timer: ["duration"], - vacuum: ["cleaning_mode", "fan_speed"], - water_heather: ["temperature", "operation_mode", "away_mode"], -}; - export interface SceneEntity extends HassEntityBase { attributes: HassEntityAttributeBase & { id?: string }; } diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index 3bba0b85d8a2..42eaaef357b0 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -37,7 +37,6 @@ import { saveScene, SCENE_IGNORED_DOMAINS, SceneEntities, - SCENE_SAVED_ATTRIBUTES, applyScene, activateScene, } from "../../../data/scene"; @@ -617,16 +616,10 @@ export class HaSceneEditor extends SubscribeMixin(LitElement) { if (!stateObj) { return; } - const domain = computeDomain(entityId); const attributes = {}; - for (const attribute in stateObj.attributes) { - if ( - SCENE_SAVED_ATTRIBUTES[domain] && - SCENE_SAVED_ATTRIBUTES[domain].includes(attribute) - ) { - attributes[attribute] = stateObj.attributes[attribute]; - } - } + Object.entries(stateObj.attributes).forEach(([key, attribute]) => { + attributes[key] = attribute; + }); return { ...attributes, state: stateObj.state }; } From b93108ae55cb4f2d74b0c4f4355dfb9afd36d77d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Nov 2019 09:52:32 +0100 Subject: [PATCH 4/4] Update ha-scene-editor.ts --- src/panels/config/scene/ha-scene-editor.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index 42eaaef357b0..a1407ee4f687 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -616,11 +616,7 @@ export class HaSceneEditor extends SubscribeMixin(LitElement) { if (!stateObj) { return; } - const attributes = {}; - Object.entries(stateObj.attributes).forEach(([key, attribute]) => { - attributes[key] = attribute; - }); - return { ...attributes, state: stateObj.state }; + return { ...stateObj.attributes, state: stateObj.state }; } private async _saveScene(): Promise {