Clickable url with dynamic payload

Is there a way to create a dashboard button with a url that is updated by payload.

It is recognized in the debug but by pressing the button nothing happens in the browser.

[
    {
        "id": "7db57965.76d468",
        "type": "ui_button",
        "z": "4e5b96c6a3d18ad9",
        "name": "",
        "group": "ca2272c3.e8396",
        "order": 1,
        "width": "4",
        "height": "1",
        "passthru": false,
        "label": "Play",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "Play",
        "payloadType": "str",
        "topic": "",
        "topicType": "str",
        "x": 190,
        "y": 1420,
        "wires": [
            [
                "6fcde5eb3496bdf2"
            ]
        ]
    },
    {
        "id": "5e1f0081.6dc3c",
        "type": "ui_template",
        "z": "4e5b96c6a3d18ad9",
        "group": "ca2272c3.e8396",
        "name": "window redirect",
        "order": 3,
        "width": 0,
        "height": 0,
        "format": "<script>\n    (function(scope) {\n    scope.$watch('msg.payload', function(data) {\n        if (data == \"Play\") {\n          window.location.href = 'msg.payload';\n        } \n    });\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 760,
        "y": 1480,
        "wires": [
            [
                "8582289.2d757d8"
            ]
        ]
    },
    {
        "id": "ece06122.7e762",
        "type": "trigger",
        "z": "4e5b96c6a3d18ad9",
        "name": "reset msg",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "nul",
        "duration": "250",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 500,
        "y": 1400,
        "wires": [
            [
                "5e1f0081.6dc3c"
            ]
        ]
    },
    {
        "id": "8582289.2d757d8",
        "type": "debug",
        "z": "4e5b96c6a3d18ad9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 1440,
        "wires": []
    },
    {
        "id": "431699ddb8ee80dd",
        "type": "function",
        "z": "4e5b96c6a3d18ad9",
        "name": "",
        "func": "var x = msg.payload;\nmsg.payload = (\"steam://connect/\") + x + (\":7777\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 1500,
        "wires": [
            [
                "ece06122.7e762"
            ]
        ]
    },
    {
        "id": "6fcde5eb3496bdf2",
        "type": "exec",
        "z": "4e5b96c6a3d18ad9",
        "command": "curl ifconfig.me",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 280,
        "y": 1480,
        "wires": [
            [
                "431699ddb8ee80dd"
            ],
            [],
            []
        ]
    },
    {
        "id": "ca2272c3.e8396",
        "type": "ui_group",
        "name": "Group 1",
        "tab": "d9bf7560.df5e58",
        "order": 1,
        "disp": true,
        "width": 6
    },
    {
        "id": "d9bf7560.df5e58",
        "type": "ui_tab",
        "name": "Test",
        "icon": "dashboard",
        "order": 9,
        "disabled": false,
        "hidden": false
    }
]

You watch msg.payload and then proof it for the value Play. But this value has been exchanged before by the url. What you can do is to watch the whole message and then proof the topic for Play. This way you can also use the payload:

[
    {
        "id": "c2f5ec181151ecf7",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "7db57965.76d468",
        "type": "ui_button",
        "z": "c2f5ec181151ecf7",
        "name": "",
        "group": "ca2272c3.e8396",
        "order": 1,
        "width": "4",
        "height": "1",
        "passthru": false,
        "label": "Play",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "Play",
        "topicType": "str",
        "x": 230,
        "y": 300,
        "wires": [
            [
                "6fcde5eb3496bdf2"
            ]
        ]
    },
    {
        "id": "5e1f0081.6dc3c",
        "type": "ui_template",
        "z": "c2f5ec181151ecf7",
        "group": "ca2272c3.e8396",
        "name": "window redirect",
        "order": 3,
        "width": 0,
        "height": 0,
        "format": "<script>\n    (function(scope) {\n    scope.$watch('msg', function(msg) {\n      if(msg!==undefined && msg!==null){\n          if (msg.topic == \"Play\") {\n            //window.location.href = msg.payload;\n            window.location.assign(msg.payload);\n          }\n      }\n    });\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 1240,
        "y": 300,
        "wires": [
            [
                "8582289.2d757d8"
            ]
        ]
    },
    {
        "id": "ece06122.7e762",
        "type": "trigger",
        "z": "c2f5ec181151ecf7",
        "name": "reset msg",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "nul",
        "duration": "250",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1040,
        "y": 300,
        "wires": [
            [
                "5e1f0081.6dc3c"
            ]
        ]
    },
    {
        "id": "8582289.2d757d8",
        "type": "debug",
        "z": "c2f5ec181151ecf7",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1430,
        "y": 300,
        "wires": []
    },
    {
        "id": "431699ddb8ee80dd",
        "type": "function",
        "z": "c2f5ec181151ecf7",
        "name": "",
        "func": "var x = msg.payload;\nmsg.payload = (\"steam://connect/\") + x + (\":7777\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 300,
        "wires": [
            [
                "ece06122.7e762"
            ]
        ]
    },
    {
        "id": "6fcde5eb3496bdf2",
        "type": "exec",
        "z": "c2f5ec181151ecf7",
        "command": "curl ifconfig.me",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 500,
        "y": 300,
        "wires": [
            [
                "431699ddb8ee80dd"
            ],
            [],
            []
        ]
    },
    {
        "id": "ca2272c3.e8396",
        "type": "ui_group",
        "name": "Group 1",
        "tab": "d9bf7560.df5e58",
        "order": 1,
        "disp": true,
        "width": 6
    },
    {
        "id": "d9bf7560.df5e58",
        "type": "ui_tab",
        "name": "Test",
        "icon": "dashboard",
        "order": 9,
        "disabled": false,
        "hidden": false
    }
]

You don't need to run an exec to find your own external IP address. You can use an http-request node.

You should also get your front-end script to output the full URL to the console, then you can see whether it is being triggered and what URL you have generated.

I'm too stupid for that. Have now used a fixed one with noip.net instead of dynamic url adjustment.
Problem solved:)
But thank you for your help

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.