From 99db784a13212dd57ebd50511313d332e991d1cc Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Tue, 16 Mar 2021 18:18:51 +0100 Subject: [PATCH] toZigbee: update color_mode on scene_recall --- converters/toZigbee.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/converters/toZigbee.js b/converters/toZigbee.js index caab2166d06fa..73ed800e969ab 100644 --- a/converters/toZigbee.js +++ b/converters/toZigbee.js @@ -3839,9 +3839,14 @@ const converters = { const isGroup = entity.constructor.name === 'Group'; const metaKey = `${sceneid}_${groupid}`; if (isGroup) { + let readColorMode = false; const membersState = {}; for (const member of entity.members) { if (member.meta.hasOwnProperty('scenes') && member.meta.scenes.hasOwnProperty(metaKey)) { + if (member.meta.scenes[metaKey].state.hasOwnProperty('color') || + member.meta.scenes[metaKey].state.hasOwnProperty('color_temp')) { + readColorMode = true; + } membersState[member.getDevice().ieeeAddr] = member.meta.scenes[metaKey].state; } else { meta.logger.warn(`Unknown scene was recalled for ${member.getDevice().ieeeAddr}, can't restore state.`); @@ -3849,9 +3854,18 @@ const converters = { } } + // read colorMode if color or color_temp in scene state, as the color_mode might have changed + if (readColorMode) { + await entity.read('lightingColorCtrl', ['colorMode']); + } return {membersState}; } else { if (entity.meta.scenes.hasOwnProperty(metaKey)) { + // read colorMode if color or color_temp in scene state, as the color_mode might have changed + if (entity.meta.scenes[metaKey].state.hasOwnProperty('color') || + entity.meta.scenes[metaKey].state.hasOwnProperty('color_temp')) { + await entity.read('lightingColorCtrl', ['colorMode']); + } return {state: entity.meta.scenes[metaKey].state}; } else { meta.logger.warn(`Unknown scene was recalled for ${entity.deviceIeeeAddress}, can't restore state.`);