From 12ca7391149a24c8e540a374556bee71624213f5 Mon Sep 17 00:00:00 2001 From: Garfonso Date: Sat, 10 Feb 2024 09:18:51 +0100 Subject: [PATCH] light on/off: fix timing / prevent unnecessary updates --- lib/converters/light.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/converters/light.js b/lib/converters/light.js index ef709992c..0551e2102 100644 --- a/lib/converters/light.js +++ b/lib/converters/light.js @@ -45,6 +45,7 @@ const SUPPORT_EFFECT = 4; async function readAttributesOnSwitchOn(entity) { const attributeValues = {}; + let updated = false; for (const attr of Object.values(entity.context.ATTRIBUTES)) { const id = attr.getId || attr.setId; if (id) { @@ -62,12 +63,15 @@ async function readAttributesOnSwitchOn(entity) { for (const [name, attribute] of Object.entries(attributeValues)) { if (entity.attributes[name] === null) { //if not updated, set value read: entity.attributes[name] = attribute; + updated = true; } } } //now tell frontend about update: - adapterData.server.updateEntityInFrontend(entity); + if (updated) { + adapterData.server.updateEntityInFrontend(entity); + } } function _lightAdvancedAddState(states, objects, entity) {