From 9257cd82b34a10986f2c92f993f77a853dd3c605 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Thu, 8 Oct 2020 17:59:39 +0200 Subject: [PATCH] Fix optimistic for groups. https://github.com/Koenkk/zigbee2mqtt/pull/4572 --- lib/extension/publish.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/extension/publish.js b/lib/extension/publish.js index 985b6b83a..eab5a86e1 100644 --- a/lib/extension/publish.js +++ b/lib/extension/publish.js @@ -223,8 +223,10 @@ class EntityPublish extends Extension { if (topic.type === 'set' && converter.convertSet) { logger.debug(`Publishing '${topic.type}' '${key}' to '${resolvedEntity.name}'`); const result = await converter.convertSet(actualTarget, key, value, meta); - const optimistic = !options.hasOwnProperty('optimistic') || options.optimistic; - if (result && result.state && optimistic) { + const isGroup = actualTarget.constructor.name == 'Group'; + // Optimistic behaviour of groups and devices is different. + const publishOptimistic = isGroup || (!options.hasOwnProperty('optimistic') || options.optimistic); + if (result && result.state && publishOptimistic) { const msg = result.state; if (endpointName) { @@ -239,7 +241,7 @@ class EntityPublish extends Extension { this.publishEntityState(resolvedEntity.settings.ID, msg); } - if (result && result.membersState && optimistic) { + if (result && result.membersState && publishOptimistic) { for (const [ieeeAddr, state] of Object.entries(result.membersState)) { this.publishEntityState(ieeeAddr, state); }