From 86a4b18b211b1cce1d5d2025d1c3299a14989a2f Mon Sep 17 00:00:00 2001 From: andrey-git Date: Wed, 4 Jan 2017 21:35:28 +0200 Subject: [PATCH 1/3] Always show the brightness slider in more-info Always show the brightness slider in more-info if it is supported. Even when the light is currently off. --- src/more-infos/more-info-light.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/more-infos/more-info-light.html b/src/more-infos/more-info-light.html index b3b9429aef4c..340b77367a8b 100644 --- a/src/more-infos/more-info-light.html +++ b/src/more-infos/more-info-light.html @@ -140,9 +140,15 @@ }, computeClassNames: function (stateObj) { - return window.hassUtil.attributeClassNames( - stateObj, ['brightness', 'rgb_color', 'color_temp', 'white_value', + var classes = window.hassUtil.attributeClassNames( + stateObj, ['rgb_color', 'color_temp', 'white_value', 'effect_list']); + // If brightness is supported - show the slider even if the attribute is + // missing (because the light is off). + if (stateObj && (stateObj.attributes.supported_features & 1)) { + classes = classes + ' has-brightness'; + } + return classes; }, effectChanged: function (effectIndex) { From 8d648be54410f6cf9cf312b068b1a1ea75ed7128 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Wed, 4 Jan 2017 22:02:00 +0200 Subject: [PATCH 2/3] Lint fix --- src/more-infos/more-info-light.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/more-infos/more-info-light.html b/src/more-infos/more-info-light.html index 340b77367a8b..d86ec11cc1d1 100644 --- a/src/more-infos/more-info-light.html +++ b/src/more-infos/more-info-light.html @@ -146,7 +146,7 @@ // If brightness is supported - show the slider even if the attribute is // missing (because the light is off). if (stateObj && (stateObj.attributes.supported_features & 1)) { - classes = classes + ' has-brightness'; + classes += ' has-brightness'; } return classes; }, From 20e6ffde9b093f59d419495170072f4d91bf47ba Mon Sep 17 00:00:00 2001 From: andrey-git Date: Thu, 5 Jan 2017 08:28:12 +0200 Subject: [PATCH 3/3] Set brightness to 0 when light is off --- src/more-infos/more-info-light.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/more-infos/more-info-light.html b/src/more-infos/more-info-light.html index d86ec11cc1d1..769bced6d3fd 100644 --- a/src/more-infos/more-info-light.html +++ b/src/more-infos/more-info-light.html @@ -132,6 +132,8 @@ } else { this.effectIndex = -1; } + } else { + this.brightnessSliderValue = 0; } this.async(function () { @@ -143,9 +145,10 @@ var classes = window.hassUtil.attributeClassNames( stateObj, ['rgb_color', 'color_temp', 'white_value', 'effect_list']); + var BRIGHTNESS_SUPPORTED = 1; // If brightness is supported - show the slider even if the attribute is // missing (because the light is off). - if (stateObj && (stateObj.attributes.supported_features & 1)) { + if (stateObj && (stateObj.attributes.supported_features & BRIGHTNESS_SUPPORTED)) { classes += ' has-brightness'; } return classes;