From 4874bb193073e6a62f33b8259247d92b7651c53a Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 8 Sep 2020 19:00:16 +0200 Subject: [PATCH] Hue: Don't falsely emit button presses at startup --- philipshue/hueremote.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/philipshue/hueremote.cpp b/philipshue/hueremote.cpp index e0a43ae5..dae1e922 100644 --- a/philipshue/hueremote.cpp +++ b/philipshue/hueremote.cpp @@ -60,14 +60,14 @@ void HueRemote::updateStates(const QVariantMap &statesMap, const QVariantMap &co emit stateChanged(); QString lastUpdate = statesMap.value("lastupdated").toString(); - - // If we never polled, just store the lastUpdate time and not emit a falsely button pressed event - if (m_lastUpdate.isEmpty()) { - m_lastUpdate = lastUpdate; - } - int buttonCode = statesMap.value("buttonevent").toInt(); + // If we never polled, just store lastUpdate/buttonCode and not emit a falsely button pressed event + if (m_lastUpdate.isEmpty() || m_lastButtonCode == -1) { + m_lastUpdate = lastUpdate; + m_lastButtonCode = buttonCode; + } + if (m_lastUpdate != lastUpdate || m_lastButtonCode != buttonCode) { m_lastUpdate = lastUpdate; m_lastButtonCode = buttonCode;