Perfy is nice but we dont need it :(. #2

This commit is contained in:
Koen Kanters
2018-04-09 20:27:32 +02:00
parent d6b26239a1
commit 26027bfb85
3 changed files with 7 additions and 17 deletions
-5
View File
@@ -601,11 +601,6 @@
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"perfy": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/perfy/-/perfy-1.1.2.tgz",
"integrity": "sha1-5KASR7xab8mfPfHaD9Oi0lU7QyM="
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
-1
View File
@@ -24,7 +24,6 @@
"homepage": "https://github.com/AndrewLinden/xiaomi-zb2mqtt#readme",
"dependencies": {
"mqtt": "*",
"perfy": "*",
"zigbee-shepherd": "*",
"yaml-config": "*"
}
+7 -11
View File
@@ -1,5 +1,3 @@
const perfy = require('perfy');
const clickLookup = {
2: 'double',
3: 'triple',
@@ -28,16 +26,14 @@ const parsers = [
// 0 = click down, 1 = click up, else = multiple clicks
if (state === 0) {
perfy.start(deviceID);
setTimeout(() => {
if (perfy.exists(deviceID)) {
publish('long');
perfy.end(deviceID);
}
}, 300); // After 300 seconds of not releasing we assume long click.
store[deviceID] = setTimeout(() => {
publish('long');
store[deviceID] = null;
}, 300); // After 300 milliseconds of not releasing we assume long click.
} else if (state === 1) {
if (perfy.exists(deviceID)) {
perfy.end(deviceID);
if (store[deviceID]) {
clearTimeout(store[deviceID]);
store[deviceID] = null;
publish('single');
}
} else {