From 83eb223169612a25af72cc961e31015d709c5e4c Mon Sep 17 00:00:00 2001 From: Tom Duijf Date: Tue, 27 Oct 2015 22:08:36 +0000 Subject: [PATCH] Add color temp slider if ct_color is supported --- src/more-infos/more-info-light.html | 12 +++++++++++- src/more-infos/more-info-light.js | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/more-infos/more-info-light.html b/src/more-infos/more-info-light.html index 123eeb5c3f..85025733a5 100644 --- a/src/more-infos/more-info-light.html +++ b/src/more-infos/more-info-light.html @@ -40,9 +40,19 @@ on-change='brightnessSliderChanged' class='flex'> + - + + diff --git a/src/more-infos/more-info-light.js b/src/more-infos/more-info-light.js index 552be2e7f4..c938c83c2d 100644 --- a/src/more-infos/more-info-light.js +++ b/src/more-infos/more-info-light.js @@ -5,7 +5,7 @@ import attributeClassNames from '../util/attribute-class-names'; require('../components/ha-color-picker'); -const ATTRIBUTE_CLASSES = ['brightness', 'xy_color']; +const ATTRIBUTE_CLASSES = ['brightness', 'xy_color', 'ct_color']; export default new Polymer({ is: 'more-info-light', @@ -20,11 +20,17 @@ export default new Polymer({ type: Number, value: 0, }, + + ctSliderValue: { + type: Number, + value: 0, + }, }, stateObjChanged(newVal) { if (newVal && newVal.state === 'on') { this.brightnessSliderValue = newVal.attributes.brightness; + this.ctSliderValue = newVal.attributes.ct_color; } this.async(() => this.fire('iron-resize'), 500); @@ -49,6 +55,17 @@ export default new Polymer({ } }, + ctSliderChanged(ev) { + const ct = parseInt(ev.target.value, 10); + + if (isNaN(ct)) return; + + serviceActions.callService('light', 'turn_on', { + entity_id: this.stateObj.entityId, + ct_color: ct, + }); + }, + colorPicked(ev) { const color = ev.detail.rgb;