From 58b2a28fe5f79de26dd5c83a79d2fbb97ae24791 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 12 Jan 2018 08:50:47 +0200 Subject: [PATCH] Make sure climate more-info dropdowns are upto date (#797) --- src/more-infos/more-info-climate.html | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/more-infos/more-info-climate.html b/src/more-infos/more-info-climate.html index a190c0bf48..9206a9defb 100644 --- a/src/more-infos/more-info-climate.html +++ b/src/more-infos/more-info-climate.html @@ -176,7 +176,8 @@ @@ -187,7 +188,8 @@ @@ -261,18 +263,6 @@ class MoreInfoClimate extends window.hassMixins.EventsMixin(Polymer.Element) { this.auxToggleChecked = newVal.attributes.aux_heat === 'on'; this.onToggleChecked = newVal.state !== 'off'; - if (newVal.attributes.fan_list) { - this.fanIndex = newVal.attributes.fan_list.indexOf(newVal.attributes.fan_mode); - } else { - this.fanIndex = -1; - } - - if (newVal.attributes.swing_list) { - this.swingIndex = newVal.attributes.swing_list.indexOf(newVal.attributes.swing_mode); - } else { - this.swingIndex = -1; - } - if (oldVal) { this._debouncer = Polymer.Debouncer.debounce( this._debouncer, @@ -290,8 +280,24 @@ class MoreInfoClimate extends window.hassMixins.EventsMixin(Polymer.Element) { if (this.stateObj.attributes.operation_list) { this.operationIndex = this.stateObj.attributes.operation_list.indexOf(this.stateObj.attributes.operation_mode); - } else { - this.operationIndex = -1; + } + } + + handleSwingListUpdate() { + // force polymer to recognize selected item change (to update actual label) + this.swingIndex = -1; + if (this.stateObj.attributes.swing_list) { + this.swingIndex = + this.stateObj.attributes.swing_list.indexOf(this.stateObj.attributes.swing_mode); + } + } + + handleFanListUpdate() { + // force polymer to recognize selected item change (to update actual label) + this.fanIndex = -1; + if (this.stateObj.attributes.fan_list) { + this.fanIndex = + this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_list); } }