Anytime Help Center

Press and Hold in Muse Automator

Rating

​​​​​​​​​Question:

​How ​​can I implement a push and hold button in Muse Automator?


Answer:

​​The easiet way to implement this is to use the trigger node to resend until it receives a message that will reset the node and stop the resending. 

The button push would activate the trigger node and the button release would stop the trigger node. You will need to configuring the node with the following so that it resets/stops when it receives false from the button release.

Reset the trigger if: msg.payload equals false


You can import the following flow into Muse Automator to see an example. ​​​​


[
    {
        "id": "fad61f2906e931d6",
        "type": "tab",
        "label": "Push and Hold",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "186a4903ac549ea9",
        "type": "inject",
        "z": "fad61f2906e931d6",
        "name": "Simulate Push",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 270,
        "y": 540,
        "wires": [
            [
                "d836dc1c80d5f2b9"
            ]
        ]
    },
    {
        "id": "fc0f7e2933db89d2",
        "type": "inject",
        "z": "fad61f2906e931d6",
        "name": "Simulate Release",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 260,
        "y": 600,
        "wires": [
            [
                "d836dc1c80d5f2b9"
            ]
        ]
    },
    {
        "id": "d5da145c44978a2b",
        "type": "UI Control",
        "z": "fad61f2906e931d6",
        "name": "Push Up",
        "mojo": {
            "type": "BUTTON",
            "path": "//1/1",
            "locator": {
                "ccode": 1,
                "cport": 1
            },
            "trigger": "PUSH",
            "state": "ON",
            "cp": "97aa9560c75b4ec6"
        },
        "x": 290,
        "y": 500,
        "wires": [
            [
                "d836dc1c80d5f2b9"
            ]
        ]
    },
    {
        "id": "97aa9560c75b4ec6",
        "type": "Control Panel",
        "z": "fad61f2906e931d6",
        "name": "10001",
        "mojo": {
            "md5": "bb4316ce8902141e756ccff34ccd4fc6",
            "tp5": "Push and Hold.TP5"
        },
        "x": 130,
        "y": 80,
        "wires": []
    },
    {
        "id": "d91688799a62c5f8",
        "type": "UI Control",
        "z": "fad61f2906e931d6",
        "name": "Release Up",
        "mojo": {
            "type": "BUTTON",
            "path": "//1/1",
            "trigger": "RELEASE",
            "state": "OFF",
            "cp": "97aa9560c75b4ec6",
            "locator": {
                "ccode": 1,
                "cport": 1
            }
        },
        "x": 280,
        "y": 640,
        "wires": [
            [
                "d836dc1c80d5f2b9"
            ]
        ]
    },
    {
        "id": "d836dc1c80d5f2b9",
        "type": "trigger",
        "z": "fad61f2906e931d6",
        "name": "",
        "op1": "",
        "op2": "0",
        "op1type": "pay",
        "op2type": "str",
        "duration": "-333",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "false",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 650,
        "y": 580,
        "wires": [
            [
                "e4c3fe7d772e98a4"
            ]
        ]
    },
    {
        "id": "e4c3fe7d772e98a4",
        "type": "function",
        "z": "fad61f2906e931d6",
        "name": "flow.count++",
        "func": "var count = flow.get('count')||0;\ncount++;\nflow.set('count',count);\nmsg.payload = count\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 930,
        "y": 580,
        "wires": [
            [
                "ad620a901e2197f4"
            ]
        ]
    },
    {
        "id": "ad620a901e2197f4",
        "type": "debug",
        "z": "fad61f2906e931d6",
        "name": "debug 40",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 580,
        "wires": []
    },
    {
        "id": "b292c1ffb6b0c47d",
        "type": "comment",
        "z": "fad61f2906e931d6",
        "name": "In this example the inject nodes are simulating the button push and release so that the example will run in simulator mode",
        "info": "",
        "x": 430,
        "y": 280,
        "wires": []
    },
    {
        "id": "958a74400a34d8f8",
        "type": "comment",
        "z": "fad61f2906e931d6",
        "name": "In this example the function node is incrementing flow.count and sending the value to the debug node",
        "info": "",
        "x": 950,
        "y": 400,
        "wires": []
    },
    {
        "id": "b55095f3e2702b9b",
        "type": "comment",
        "z": "fad61f2906e931d6",
        "name": "In a live system you would connect the trigger node to whichever command you want to repeat whlie the button is held",
        "info": "",
        "x": 1000,
        "y": 440,
        "wires": []
    },
    {
        "id": "0696f836834bdc36",
        "type": "inject",
        "z": "fad61f2906e931d6",
        "name": "Simulate Push",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 270,
        "y": 820,
        "wires": [
            [
                "f93b59cf07a03e6f"
            ]
        ]
    },
    {
        "id": "010d2e0a3c3926bf",
        "type": "inject",
        "z": "fad61f2906e931d6",
        "name": "Simulate Release",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 260,
        "y": 880,
        "wires": [
            [
                "f93b59cf07a03e6f"
            ]
        ]
    },
    {
        "id": "f8a897a7bf70f325",
        "type": "UI Control",
        "z": "fad61f2906e931d6",
        "name": "Push Down",
        "mojo": {
            "type": "BUTTON",
            "path": "//1/2",
            "locator": {
                "ccode": 2,
                "cport": 1
            },
            "trigger": "PUSH",
            "state": "ON",
            "cp": "97aa9560c75b4ec6"
        },
        "x": 280,
        "y": 780,
        "wires": [
            [
                "f93b59cf07a03e6f"
            ]
        ]
    },
    {
        "id": "f3b52e167c58289b",
        "type": "UI Control",
        "z": "fad61f2906e931d6",
        "name": "Release Down",
        "mojo": {
            "type": "BUTTON",
            "path": "//1/2",
            "trigger": "RELEASE",
            "state": "OFF",
            "cp": "97aa9560c75b4ec6",
            "locator": {
                "ccode": 2,
                "cport": 1
            }
        },
        "x": 270,
        "y": 920,
        "wires": [
            [
                "f93b59cf07a03e6f"
            ]
        ]
    },
    {
        "id": "f93b59cf07a03e6f",
        "type": "trigger",
        "z": "fad61f2906e931d6",
        "name": "",
        "op1": "",
        "op2": "0",
        "op1type": "pay",
        "op2type": "str",
        "duration": "-333",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "false",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 650,
        "y": 860,
        "wires": [
            [
                "f414541f826a4f5d"
            ]
        ]
    },
    {
        "id": "f414541f826a4f5d",
        "type": "function",
        "z": "fad61f2906e931d6",
        "name": "flow.count--",
        "func": "var count = flow.get('count')||0;\ncount--;\nflow.set('count',count);\nmsg.payload = count\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 930,
        "y": 860,
        "wires": [
            [
                "a50683bff62ecf4e"
            ]
        ]
    },
    {
        "id": "a50683bff62ecf4e",
        "type": "debug",
        "z": "fad61f2906e931d6",
        "name": "debug 41",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 860,
        "wires": []
    }
]

 


Downloads

Product

 

Topic

Programming

Related Articles

Last modified at 7/29/2024 1:38 PM by PRO Knowledge Base
Top