Fix occationally lost button events

This commit is contained in:
Michael Zanetti 2020-04-03 18:13:44 +02:00
parent 686a595d8f
commit f4b0badfd8
3 changed files with 8 additions and 5 deletions

View File

@ -66,10 +66,12 @@ void HueRemote::updateStates(const QVariantMap &statesMap, const QVariantMap &co
m_lastUpdate = lastUpdate;
}
if (m_lastUpdate != lastUpdate) {
m_lastUpdate = lastUpdate;
int buttonCode = statesMap.value("buttonevent").toInt();
if (m_lastUpdate != lastUpdate || m_lastButtonCode != buttonCode) {
m_lastUpdate = lastUpdate;
m_lastButtonCode = buttonCode;
int buttonCode = statesMap.value("buttonevent").toInt();
qCDebug(dcPhilipsHue) << "button pressed" << buttonCode;
emit buttonPressed(buttonCode);

View File

@ -54,6 +54,7 @@ public:
private:
int m_battery;
QString m_lastUpdate;
int m_lastButtonCode = -1;
signals:
void stateChanged();

View File

@ -1371,9 +1371,9 @@ void IntegrationPluginPhilipsHue::processBridgeSensorDiscoveryResponse(Thing *th
QString uuid = sensorMap.value("uniqueid").toString();
QString model = sensorMap.value("modelid").toString();
qCDebug(dcPhilipsHue()) << "Found sensor on bridge:" << model << uuid;
// qCDebug(dcPhilipsHue()) << "Found sensor on bridge:" << model << uuid;
foreach (HueRemote* remote, remotesToRemove) {
qCDebug(dcPhilipsHue()) << " - Checking remote to remove" << remote->modelId() << remote->uuid();
// qCDebug(dcPhilipsHue()) << " - Checking remote to remove" << remote->modelId() << remote->uuid();
if (remote->uuid() == uuid) {
remotesToRemove.removeAll(remote);
break;