Hue: Don't falsely emit button presses at startup

This commit is contained in:
Michael Zanetti 2020-09-08 19:00:16 +02:00
parent 34ac58feaa
commit 4874bb1930

View File

@ -60,14 +60,14 @@ void HueRemote::updateStates(const QVariantMap &statesMap, const QVariantMap &co
emit stateChanged(); emit stateChanged();
QString lastUpdate = statesMap.value("lastupdated").toString(); 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(); 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) { if (m_lastUpdate != lastUpdate || m_lastButtonCode != buttonCode) {
m_lastUpdate = lastUpdate; m_lastUpdate = lastUpdate;
m_lastButtonCode = buttonCode; m_lastButtonCode = buttonCode;