Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "521c610a20a966a4",
- "type": "function",
- "z": "f6b1667f7ee0d1b0",
- "name": "Gombnyomást számol",
- "func": "var buttonPressCount = flow.get(\"buttonPressCount\") || 0;\nvar lastPressTime = context.get(\"lastPressTime\") || 0;\nvar threshold = 1500;\nvar currentTime = new Date().getTime();\n\n\nvar elapsedTime = currentTime - lastPressTime;\n\n// Ellenőrzi a gomb állapotát és számolja a lenyomásokat\nif (msg.payload.buttonevent === 4002) {\n buttonPressCount++;\n // Frissíti a flow változót az utolsó gombnyomás időpontjával\n context.set(\"lastPressTime\", currentTime);\n flow.set(\"buttonPressCount\", buttonPressCount);\n node.status({ fill: \"grey\", shape: \"ring\", text: buttonPressCount });\n return;\n} else {\n // Ellenőrzi, hogy az eltelt idő kevesebb-e, mint a küszöbérték\n if (lastPressTime === 0) {\n return;\n }\n if (elapsedTime > threshold) {\n msg.payload = buttonPressCount;\n msg.press = \"press\";\n buttonPressCount = 0;\n context.set(\"lastPressTime\",0);\n flow.set(\"buttonPressCount\", buttonPressCount);\n node.status({ fill: \"grey\", shape: \"ring\", text: buttonPressCount });\n return msg;\n } \n}\n\n",
- "outputs": 1,
- "noerr": 0,
- "initialize": "",
- "finalize": "",
- "libs": [],
- "x": 540,
- "y": 4560,
- "wires": [
- [
- "fcf604040abf79f3"
- ]
- ]
- },
- {
- "id": "fcf604040abf79f3",
- "type": "debug",
- "z": "f6b1667f7ee0d1b0",
- "name": "debug 67",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "false",
- "statusVal": "",
- "statusType": "auto",
- "x": 760,
- "y": 4560,
- "wires": []
- },
- {
- "id": "fe8c05c93a1a7f43",
- "type": "inject",
- "z": "f6b1667f7ee0d1b0",
- "name": "",
- "props": [
- {
- "p": "payload"
- },
- {
- "p": "topic",
- "vt": "str"
- }
- ],
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "topic": "",
- "payload": "{\"buttonevent\" : 4002}",
- "payloadType": "json",
- "x": 240,
- "y": 4560,
- "wires": [
- [
- "521c610a20a966a4",
- "3e9a208e53950bcb"
- ]
- ]
- },
- {
- "id": "09654d19da0190da",
- "type": "change",
- "z": "f6b1667f7ee0d1b0",
- "name": "",
- "rules": [
- {
- "t": "set",
- "p": "payload",
- "pt": "msg",
- "to": "{\"buttonevent\" : 0}",
- "tot": "json"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 520,
- "y": 4660,
- "wires": [
- [
- "521c610a20a966a4"
- ]
- ]
- },
- {
- "id": "3e9a208e53950bcb",
- "type": "delay",
- "z": "f6b1667f7ee0d1b0",
- "name": "",
- "pauseType": "delay",
- "timeout": "1600",
- "timeoutUnits": "milliseconds",
- "rate": "1",
- "nbRateUnits": "1",
- "rateUnits": "second",
- "randomFirst": "1",
- "randomLast": "5",
- "randomUnits": "seconds",
- "drop": false,
- "allowrate": false,
- "outputs": 1,
- "x": 320,
- "y": 4660,
- "wires": [
- [
- "09654d19da0190da"
- ]
- ]
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement