Skip to content

Commit

Permalink
Emulate release event for Aqara Opple (#1634)
Browse files Browse the repository at this point in the history
* Emulate release event for Aqara Opple 

Aqara Opple does not generate a release event when pressed for more than 5 seconds.
After 5 seconds of not releasing we assume release.

* fix
  • Loading branch information
kirovilya authored Oct 7, 2020
1 parent a66805f commit 8f29a7a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5075,6 +5075,22 @@ const converters = {
};
const btn = msg.endpoint.ID;
const value = msg.data.presentValue;
const deviceID = msg.device.ieeeAddr;
if (store[deviceID]) {
clearTimeout(store[deviceID]);
store[deviceID] = null;
}

// 0 = hold
if (value === 0) {
// Aqara Opple does not generate a release event when pressed for more than 5 seconds
// After 5 seconds of not releasing we assume release.
store[deviceID] = setTimeout(() => {
publish({action: `button_${btn}_release`});
clearTimeout(store[deviceID]);
store[deviceID] = null;
}, 5000);
}
return {action: `button_${btn}_${actionLookup[value]}`};
},
},
Expand Down

0 comments on commit 8f29a7a

Please sign in to comment.