From f281411b2e8de629b968b104d181cf516770c267 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 Dec 2019 16:33:21 +0100 Subject: [PATCH] Set the light property before the any_on/all_on check on the group --- .../http/static/js/plugins/light.hue/index.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/platypush/backend/http/static/js/plugins/light.hue/index.js b/platypush/backend/http/static/js/plugins/light.hue/index.js index 0e431969..52fc3e6c 100644 --- a/platypush/backend/http/static/js/plugins/light.hue/index.js +++ b/platypush/backend/http/static/js/plugins/light.hue/index.js @@ -25,7 +25,7 @@ Vue.component('light-hue', { } this.groups[groupId].scenes = {}; - var lights = {}; + let lights = {}; for (const lightId of this.groups[groupId].lights) { lights[lightId] = this.lights[lightId]; @@ -146,7 +146,8 @@ Vue.component('light-hue', { } } - groups[groupId].lights.push(lightId) + groups[groupId].lights.push(lightId); + if (groups[groupId].lights.length == Object.values(group.lights).length) { groups[groupId].all_on = true; } @@ -178,7 +179,13 @@ Vue.component('light-hue', { }, onUnitInput: function(event) { - var groups = this.lights[event.id].groups; + for (let attr of ['on', 'hue', 'sat', 'bri', 'xy', 'ct']) { + if (attr in event) { + this.lights[event.id].state[attr] = event[attr]; + } + } + + let groups = this.lights[event.id].groups; for (const [groupId, group] of Object.entries(groups)) { if (event.on === true) { this.groups[groupId].state.any_on = true; @@ -188,12 +195,6 @@ Vue.component('light-hue', { this.groups[groupId].state.any_on = Object.values(group.lights).filter((l) => l.state.on).length > 0; } } - - for (var attr of ['on', 'hue', 'sat', 'bri', 'xy', 'ct']) { - if (attr in event) { - this.lights[event.id].state[attr] = event[attr]; - } - } }, eventHandler: function(event) { @@ -203,7 +204,7 @@ Vue.component('light-hue', { id: event.light_id, }); } else if ('group_id' in event) { - var args = { + let args = { id: event.group_id, state: { ...event,