Variable in Function Node einfügen?

Node-RED als CCU3/RaspberryMatic Addon, WebApp, HomeKit, ...

Moderator: Co-Administratoren

Brainpurge
Beiträge: 106
Registriert: 08.11.2017, 17:56
System: CCU und Access Point
Hat sich bedankt: 16 Mal

Re: Variable in Function Node einfügen?

Beitrag von Brainpurge » 23.01.2023, 19:35

Hallo,

mit dem {{{ulr}}} verstehe ich nicht ganz, wie bekomme ich diesen in einem anderen Flow mit einer anderen Variable hin? Siehe mein Post über dir

Habs hinbekommen:

Code: Alles auswählen

[{"id":"dec43054.8e28b","type":"tab","label":"Zitat","disabled":false,"info":""},{"id":"83ba2301.ff32a","type":"delay","z":"dec43054.8e28b","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":120,"wires":[["b66352ec.c2096"]]},{"id":"d267394.12622c8","type":"delay","z":"dec43054.8e28b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":180,"wires":[["954c5b44.08d8b8"]]},{"id":"b86ddc6e.2b298","type":"delay","z":"dec43054.8e28b","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":240,"wires":[["eb5e2d57.d5df1"]]},{"id":"995d1c58.94753","type":"inject","z":"dec43054.8e28b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic","payload":"payload","payloadType":"msg","x":100,"y":200,"wires":[["83ba2301.ff32a"]]},{"id":"90e43364.18e3a","type":"http in","z":"dec43054.8e28b","name":"","url":"/zitat","method":"get","upload":false,"swaggerDoc":"","x":120,"y":80,"wires":[["83ba2301.ff32a"]]},{"id":"d9bc97a0.31bc28","type":"castv2-sender","z":"dec43054.8e28b","name":"Küche","connection":"f71d550e.d9b078","x":1010,"y":200,"wires":[[]],"outputLabels":["msg.payload"]},{"id":"eb959b45.aea098","type":"ccu-sysvar","z":"dec43054.8e28b","name":"URLVariable_Zitat_AN","ccuConfig":"38263145.35ea0e","topic":"ReGaHSS/${Name}","change":false,"cache":true,"x":160,"y":400,"wires":[["6bbfba53.6b4fa4"]]},{"id":"a3cc7324.27016","type":"debug","z":"dec43054.8e28b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":360,"wires":[]},{"id":"f9eca763.70e958","type":"ui_toast","z":"dec43054.8e28b","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":930,"y":400,"wires":[]},{"id":"bb38bbc2.754c98","type":"ui_button","z":"dec43054.8e28b","name":"","group":"46fbe67a.90cd18","order":3,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"URLVariable","payloadType":"global","topic":"Geht?","topicType":"str","x":710,"y":400,"wires":[["f9eca763.70e958","a3cc7324.27016"]]},{"id":"6bbfba53.6b4fa4","type":"change","z":"dec43054.8e28b","name":"","rules":[{"t":"set","p":"URLVariable_Zitat_AN","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":400,"wires":[["bb38bbc2.754c98"]]},{"id":"2b0129f7.e17f46","type":"change","z":"dec43054.8e28b","name":"Close","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"app\":\"DefaultMediaReceiver\",\"type\":\"CLOSE\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":300,"wires":[["d9bc97a0.31bc28"]]},{"id":"eb5e2d57.d5df1","type":"change","z":"dec43054.8e28b","name":"Volume auf 10","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"app\":\"DefaultMediaReceiver\",\"type\":\"VOLUME\",\"volume\":10}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":240,"wires":[["d9bc97a0.31bc28","2b0129f7.e17f46"]]},{"id":"b66352ec.c2096","type":"change","z":"dec43054.8e28b","name":"Volume auf 40","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"app\":\"DefaultMediaReceiver\",\"type\":\"VOLUME\",\"volume\":40}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":120,"wires":[["d267394.12622c8","d9bc97a0.31bc28"]]},{"id":"99b7d189.7b493","type":"template","z":"dec43054.8e28b","name":"Zitat","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n\"type\": \"MEDIA\",\n\"contentType\": \"audio/vnd.wav\",\n\"streamType\": \"BUFFERED\",\n    \"media\": [\n     { \"url\": \"{{{ulr}}}\" } \n    ]\n}","output":"json","x":770,"y":180,"wires":[["b86ddc6e.2b298","d9bc97a0.31bc28"]]},{"id":"96d48646.4401d8","type":"inject","z":"dec43054.8e28b","name":"hab ich nicht","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic","payload":"ulr...","payloadType":"str","x":150,"y":340,"wires":[["eb959b45.aea098"]]},{"id":"954c5b44.08d8b8","type":"change","z":"dec43054.8e28b","name":"","rules":[{"t":"set","p":"ulr","pt":"msg","to":"URLVariable_Zitat_AN","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":180,"wires":[["99b7d189.7b493"]]},{"id":"f71d550e.d9b078","type":"castv2-connection","name":"Küche","target":"Küche","host":"192.168.178.70","port":"8009"},{"id":"38263145.35ea0e","type":"ccu-connection","name":"localhost","host":"localhost","regaEnabled":true,"bcrfEnabled":true,"iprfEnabled":true,"virtEnabled":true,"bcwiEnabled":false,"cuxdEnabled":false,"regaPoll":true,"regaInterval":"120","rpcPingTimeout":"60","rpcInitAddress":"127.0.0.1","rpcServerHost":"192.168.178.169","rpcBinPort":"2047","rpcXmlPort":"2048","tls":false,"inSecure":false,"authentication":false,"username":"","password":"","queueTimeout":"5000","queuePause":"350","contextStore":"default"},{"id":"46fbe67a.90cd18","type":"ui_group","name":"Variablen","tab":"36fb2145.947dee","order":1,"disp":true,"width":"6","collapse":false},{"id":"36fb2145.947dee","type":"ui_tab","name":"Variablen","icon":"dashboard","order":2}]
CCU 3 mit Firmware 3.67.10 + AccessPoint mit Firmware 2.4.28

Benutzeravatar
Henke
Beiträge: 1520
Registriert: 27.06.2022, 20:51
System: CCU
Hat sich bedankt: 140 Mal
Danksagung erhalten: 306 Mal

Re: Variable in Function Node einfügen?

Beitrag von Henke » 23.01.2023, 21:13

Dazu muss der Flow umgebaut werden, damit er flexibler einsetzbar ist:

Code: Alles auswählen

[
    {
        "id": "825926fd019a49dd",
        "type": "delay",
        "z": "34462754edbaf114",
        "name": "Variable Verzögerung",
        "pauseType": "delayv",
        "timeout": "10",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 600,
        "y": 1040,
        "wires": [
            [
                "e40b47b7af2f7dbf"
            ]
        ]
    },
    {
        "id": "23d6afc33c4310a6",
        "type": "delay",
        "z": "34462754edbaf114",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 580,
        "y": 1100,
        "wires": [
            [
                "310544541b3e3a63"
            ]
        ]
    },
    {
        "id": "75698b30cf19c8b9",
        "type": "delay",
        "z": "34462754edbaf114",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 580,
        "y": 980,
        "wires": [
            [
                "63e17441c0cffda4"
            ]
        ]
    },
    {
        "id": "644c1441a2e7a27d",
        "type": "inject",
        "z": "34462754edbaf114",
        "name": "",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 860,
        "wires": [
            [
                "97e105acd1615188"
            ]
        ]
    },
    {
        "id": "aad57fdfbc9d69ab",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "Volume auf 40",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"app\":\"DefaultMediaReceiver\",\"type\":\"VOLUME\",\"volume\":40}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 920,
        "wires": [
            [
                "75698b30cf19c8b9",
                "9c9ba3edcae7e04c"
            ]
        ]
    },
    {
        "id": "e40b47b7af2f7dbf",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "Volume auf 10",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"app\":\"DefaultMediaReceiver\",\"type\":\"VOLUME\",\"volume\":10}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 800,
        "y": 1040,
        "wires": [
            [
                "23d6afc33c4310a6",
                "9c9ba3edcae7e04c"
            ]
        ]
    },
    {
        "id": "310544541b3e3a63",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "Close",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"app\":\"DefaultMediaReceiver\",\"type\":\"CLOSE\"}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 770,
        "y": 1100,
        "wires": [
            [
                "9c9ba3edcae7e04c"
            ]
        ]
    },
    {
        "id": "9c9ba3edcae7e04c",
        "type": "debug",
        "z": "34462754edbaf114",
        "name": "hab ich nicht",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1530,
        "y": 1080,
        "wires": []
    },
    {
        "id": "97e105acd1615188",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "get URLVariable",
        "rules": [
            {
                "t": "set",
                "p": "ulr",
                "pt": "msg",
                "to": "URLVariable",
                "tot": "global"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 180,
        "y": 900,
        "wires": [
            [
                "e2428b8299c7f7a8"
            ]
        ]
    },
    {
        "id": "63e17441c0cffda4",
        "type": "template",
        "z": "34462754edbaf114",
        "name": "Ausgabe",
        "field": "Ausgabe",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n\"type\": \"MEDIA\",\n\"contentType\": \"audio/vnd.wav\",\n\"streamType\": \"BUFFERED\"\n}",
        "output": "json",
        "x": 760,
        "y": 980,
        "wires": [
            [
                "2069df4e3391924d"
            ]
        ]
    },
    {
        "id": "e9da6d3957f1fb62",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "set Ausgabe nach payload",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "Ausgabe",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 980,
        "wires": [
            [
                "9c9ba3edcae7e04c",
                "825926fd019a49dd"
            ]
        ]
    },
    {
        "id": "e2428b8299c7f7a8",
        "type": "template",
        "z": "34462754edbaf114",
        "name": "Setup Wohnzimmer",
        "field": "Setup",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n  \"media\": [\n    {\n      \"url\": \"http://192.168.178.169/addons/sounds/im-wohnzimmer.wav\"\n    },\n    {\n      \"url\": \"{{{ulr}}}\"\n    }\n  ],\n  \"delay\": 10000\n}",
        "output": "json",
        "x": 190,
        "y": 940,
        "wires": [
            [
                "aad57fdfbc9d69ab",
                "e2353c6c563927c5"
            ]
        ]
    },
    {
        "id": "2069df4e3391924d",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "Ausgabe.media",
                "pt": "msg",
                "to": "Setup.media",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 980,
        "y": 980,
        "wires": [
            [
                "e9da6d3957f1fb62"
            ]
        ]
    },
    {
        "id": "e6a7de3a09ba9802",
        "type": "http in",
        "z": "34462754edbaf114",
        "name": "",
        "url": "/zitat",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 180,
        "y": 1140,
        "wires": [
            [
                "d33badc84fb4621a"
            ]
        ]
    },
    {
        "id": "91ee3bc2038df3e3",
        "type": "template",
        "z": "34462754edbaf114",
        "name": "Setup Zitat",
        "field": "Setup",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n  \"media\": [\n    {\n      \"url\": \"{{{ulr}}}\"\n    }\n  ],\n  \"delay\": 15000\n}",
        "output": "json",
        "x": 150,
        "y": 1220,
        "wires": [
            [
                "aad57fdfbc9d69ab",
                "e2353c6c563927c5"
            ]
        ]
    },
    {
        "id": "d33badc84fb4621a",
        "type": "change",
        "z": "34462754edbaf114",
        "name": "get URLVariable_Zitat_AN",
        "rules": [
            {
                "t": "set",
                "p": "ulr",
                "pt": "msg",
                "to": "URLVariable_Zitat_AN",
                "tot": "global"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 190,
        "y": 1180,
        "wires": [
            [
                "91ee3bc2038df3e3"
            ]
        ]
    },
    {
        "id": "e2353c6c563927c5",
        "type": "debug",
        "z": "34462754edbaf114",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 880,
        "wires": []
    }
]
Da kannst du dann beliebig die Eingänge mit dem Setup anpassen.

Antworten

Zurück zu „RedMatic“