josefkyrian

nodered 1 - core

May 31st, 2022 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 51.05 KB | None | 0 0
  1. [
  2.     {
  3.         "id": "1701a0.212bae61",
  4.         "type": "tab",
  5.         "label": "core",
  6.         "disabled": false,
  7.         "info": ""
  8.     },
  9.     {
  10.         "id": "dc52cc05.e78c1",
  11.         "type": "actionflows_in",
  12.         "z": "1701a0.212bae61",
  13.         "name": "core.rpc",
  14.         "priority": "50",
  15.         "links": [],
  16.         "scope": "global",
  17.         "x": 109.00003051757812,
  18.         "y": 168.00000190734863,
  19.         "wires": [
  20.             [
  21.                 "4d9adedb.b0b6e"
  22.             ]
  23.         ]
  24.     },
  25.     {
  26.         "id": "86794597.ab6358",
  27.         "type": "jsonrpc-call",
  28.         "z": "1701a0.212bae61",
  29.         "name": "",
  30.         "method": "",
  31.         "client": "36ca1673.3376ea",
  32.         "x": 418.0000305175781,
  33.         "y": 184,
  34.         "wires": [
  35.             [
  36.                 "948aa258.1d622",
  37.                 "77cb98d7.0bf1e8"
  38.             ]
  39.         ]
  40.     },
  41.     {
  42.         "id": "3c61c551.51b97a",
  43.         "type": "inject",
  44.         "z": "1701a0.212bae61",
  45.         "name": "",
  46.         "repeat": "",
  47.         "crontab": "",
  48.         "once": false,
  49.         "onceDelay": 0.1,
  50.         "topic": "",
  51.         "payload": "",
  52.         "payloadType": "date",
  53.         "x": 142.00003051757812,
  54.         "y": 241,
  55.         "wires": [
  56.             [
  57.                 "6a1448a8.d39a58"
  58.             ]
  59.         ]
  60.     },
  61.     {
  62.         "id": "6a1448a8.d39a58",
  63.         "type": "function",
  64.         "z": "1701a0.212bae61",
  65.         "name": "",
  66.         "func": "msg.method = \"kua\";\nreturn msg;",
  67.         "outputs": 1,
  68.         "noerr": 0,
  69.         "x": 274.0000305175781,
  70.         "y": 241,
  71.         "wires": [
  72.             [
  73.                 "86794597.ab6358"
  74.             ]
  75.         ]
  76.     },
  77.     {
  78.         "id": "948aa258.1d622",
  79.         "type": "debug",
  80.         "z": "1701a0.212bae61",
  81.         "name": "",
  82.         "active": false,
  83.         "tosidebar": true,
  84.         "console": false,
  85.         "tostatus": false,
  86.         "complete": "false",
  87.         "statusVal": "",
  88.         "statusType": "auto",
  89.         "x": 632.0000305175781,
  90.         "y": 186,
  91.         "wires": []
  92.     },
  93.     {
  94.         "id": "4d9adedb.b0b6e",
  95.         "type": "function",
  96.         "z": "1701a0.212bae61",
  97.         "name": "",
  98.         "func": "msg.method = msg.method;\nmsg.payload = msg.payload;\nreturn msg;",
  99.         "outputs": 1,
  100.         "noerr": 0,
  101.         "initialize": "",
  102.         "finalize": "",
  103.         "x": 250.00003051757812,
  104.         "y": 174,
  105.         "wires": [
  106.             [
  107.                 "86794597.ab6358"
  108.             ]
  109.         ]
  110.     },
  111.     {
  112.         "id": "77cb98d7.0bf1e8",
  113.         "type": "actionflows_out",
  114.         "z": "1701a0.212bae61",
  115.         "name": "action out",
  116.         "links": [],
  117.         "x": 625.0000381469727,
  118.         "y": 258.00000381469727,
  119.         "wires": []
  120.     },
  121.     {
  122.         "id": "c2bbad49.8fce7",
  123.         "type": "inject",
  124.         "z": "1701a0.212bae61",
  125.         "name": "call rpc in JS",
  126.         "repeat": "",
  127.         "crontab": "",
  128.         "once": false,
  129.         "onceDelay": 0.1,
  130.         "topic": "",
  131.         "payload": "",
  132.         "payloadType": "date",
  133.         "x": 254.00006675720215,
  134.         "y": 362.00000286102295,
  135.         "wires": [
  136.             [
  137.                 "464d70c2.7cc82"
  138.             ]
  139.         ]
  140.     },
  141.     {
  142.         "id": "464d70c2.7cc82",
  143.         "type": "function",
  144.         "z": "1701a0.212bae61",
  145.         "name": "",
  146.         "func": "(async () => {\n    const af = global.get('actionflows');\n    \n    const getWindowPosition = async (name) => {\n        const resMsg = await af.invoke('core.rpc', {\n            method: \"window.getPosition\",\n            payload: [name],\n        });\n        return resMsg.payload.position;\n    };\n    /*\n    resMsg = await af.invoke('core.rpc', {\n        method: \"window.getPosition\",\n        payload: [\"loft-bedroom\"],\n    });*/\n    node.send({\n        payload: `Stav okna ${await getWindowPosition('loft-bedroom')}`\n    });\n})();\n",
  147.         "outputs": 1,
  148.         "noerr": 0,
  149.         "initialize": "",
  150.         "finalize": "",
  151.         "x": 414.00008392333984,
  152.         "y": 361.99999046325684,
  153.         "wires": [
  154.             [
  155.                 "df0446b8.06ae58"
  156.             ]
  157.         ]
  158.     },
  159.     {
  160.         "id": "df0446b8.06ae58",
  161.         "type": "debug",
  162.         "z": "1701a0.212bae61",
  163.         "name": "",
  164.         "active": false,
  165.         "tosidebar": true,
  166.         "console": false,
  167.         "tostatus": false,
  168.         "complete": "false",
  169.         "x": 582.000114440918,
  170.         "y": 363.99999046325684,
  171.         "wires": []
  172.     },
  173.     {
  174.         "id": "fe075d44.64aa",
  175.         "type": "comment",
  176.         "z": "1701a0.212bae61",
  177.         "name": "rpc via actionsflows",
  178.         "info": "(async () => {\n    const af = global.get('actionflows');\n    \n    resMsg = await af.invoke('rpc', {\n        method: \"window.getPosition\",\n        payload: [\"loft-bedroom\"],\n    });\n    node.send(resMsg);\n})();\n",
  179.         "x": 126.00003051757812,
  180.         "y": 105,
  181.         "wires": []
  182.     },
  183.     {
  184.         "id": "9012924d.79775",
  185.         "type": "comment",
  186.         "z": "1701a0.212bae61",
  187.         "name": "test rpc call",
  188.         "info": "",
  189.         "x": 227.00006866455078,
  190.         "y": 316.9999895095825,
  191.         "wires": []
  192.     },
  193.     {
  194.         "id": "cc6ba16c.ba465",
  195.         "type": "tail",
  196.         "z": "1701a0.212bae61",
  197.         "d": true,
  198.         "name": "",
  199.         "filetype": "text",
  200.         "split": "[\\r]{0,1}\\n",
  201.         "filename": "/home/gibo/.node-red/nodered.log",
  202.         "inputs": 0,
  203.         "x": 1264.9999694824219,
  204.         "y": 237.00004959106445,
  205.         "wires": [
  206.             [
  207.                 "7eddee49.b2b8d"
  208.             ]
  209.         ]
  210.     },
  211.     {
  212.         "id": "7eddee49.b2b8d",
  213.         "type": "debug",
  214.         "z": "1701a0.212bae61",
  215.         "name": "",
  216.         "active": false,
  217.         "tosidebar": true,
  218.         "console": false,
  219.         "tostatus": false,
  220.         "complete": "false",
  221.         "statusVal": "",
  222.         "statusType": "auto",
  223.         "x": 1555.799976348877,
  224.         "y": 254.00005912780762,
  225.         "wires": []
  226.     },
  227.     {
  228.         "id": "d34d5c7b.ad36d",
  229.         "type": "comment",
  230.         "z": "1701a0.212bae61",
  231.         "name": "tail log",
  232.         "info": "",
  233.         "x": 1124.8000030517578,
  234.         "y": 179.00003337860107,
  235.         "wires": []
  236.     },
  237.     {
  238.         "id": "564d3f68.5d431",
  239.         "type": "actionflows_in",
  240.         "z": "1701a0.212bae61",
  241.         "name": "core.db.query",
  242.         "priority": "50",
  243.         "links": [],
  244.         "scope": "global",
  245.         "x": 127.00001525878906,
  246.         "y": 620.0000257492065,
  247.         "wires": [
  248.             [
  249.                 "82b19538.31eb68"
  250.             ]
  251.         ]
  252.     },
  253.     {
  254.         "id": "82b19538.31eb68",
  255.         "type": "function",
  256.         "z": "1701a0.212bae61",
  257.         "name": "databases list",
  258.         "func": "const databases = {\n    'smarthouse': 0,\n    'xxx': 1,\n};\n\nmsg.topic = msg.query;\nmsg.payload = msg.values;\n\nconst selectedDatabase = databases[msg.database];\n\nconst res = [];\nfor (const outputNumber of new Set(Object.values(databases))) {\n    res.push(selectedDatabase === outputNumber ? msg : null);\n}\n\nreturn res;",
  259.         "outputs": 3,
  260.         "noerr": 0,
  261.         "initialize": "",
  262.         "finalize": "",
  263.         "libs": [],
  264.         "x": 352.0000228881836,
  265.         "y": 623.0000247955322,
  266.         "wires": [
  267.             [
  268.                 "492b7203.2464fc"
  269.             ],
  270.             [],
  271.             []
  272.         ]
  273.     },
  274.     {
  275.         "id": "e6677b6.2708f88",
  276.         "type": "actionflows_out",
  277.         "z": "1701a0.212bae61",
  278.         "name": "action out",
  279.         "links": [],
  280.         "x": 805.0000267028809,
  281.         "y": 643.0000267028809,
  282.         "wires": []
  283.     },
  284.     {
  285.         "id": "492b7203.2464fc",
  286.         "type": "mysql",
  287.         "z": "1701a0.212bae61",
  288.         "mydb": "76a2023f.8c254c",
  289.         "name": "",
  290.         "x": 589.0000228881836,
  291.         "y": 603.0000257492065,
  292.         "wires": [
  293.             [
  294.                 "e6677b6.2708f88"
  295.             ]
  296.         ]
  297.     },
  298.     {
  299.         "id": "f7748054.51ff6",
  300.         "type": "comment",
  301.         "z": "1701a0.212bae61",
  302.         "name": "db query via actionflows",
  303.         "info": "",
  304.         "x": 139.80001831054688,
  305.         "y": 532.0000152587891,
  306.         "wires": []
  307.     },
  308.     {
  309.         "id": "db217951.75efa8",
  310.         "type": "inject",
  311.         "z": "1701a0.212bae61",
  312.         "name": "test",
  313.         "props": [
  314.             {
  315.                 "p": "payload"
  316.             },
  317.             {
  318.                 "p": "topic",
  319.                 "vt": "str"
  320.             }
  321.         ],
  322.         "repeat": "",
  323.         "crontab": "",
  324.         "once": false,
  325.         "onceDelay": 0.1,
  326.         "topic": "",
  327.         "payload": "",
  328.         "payloadType": "date",
  329.         "x": 194.00003051757812,
  330.         "y": 775.0000457763672,
  331.         "wires": [
  332.             [
  333.                 "3ca93c76.094874"
  334.             ]
  335.         ]
  336.     },
  337.     {
  338.         "id": "fd527c9.2ad4f8",
  339.         "type": "debug",
  340.         "z": "1701a0.212bae61",
  341.         "name": "",
  342.         "active": false,
  343.         "tosidebar": true,
  344.         "console": false,
  345.         "tostatus": false,
  346.         "complete": "false",
  347.         "statusVal": "",
  348.         "statusType": "auto",
  349.         "x": 574.0000381469727,
  350.         "y": 776.0000448226929,
  351.         "wires": []
  352.     },
  353.     {
  354.         "id": "3ca93c76.094874",
  355.         "type": "function",
  356.         "z": "1701a0.212bae61",
  357.         "name": "",
  358.         "func": "const af = global.get('actionflows');\n\nconst resMsg = await af.invoke('core.db.query', {\n    database: 'smarthouse',\n    query: \"SELECT * FROM radio_station\",\n    values: [],\n});\n\nreturn resMsg;",
  359.         "outputs": 1,
  360.         "noerr": 0,
  361.         "initialize": "",
  362.         "finalize": "",
  363.         "libs": [],
  364.         "x": 372.0000343322754,
  365.         "y": 782.0000467300415,
  366.         "wires": [
  367.             [
  368.                 "fd527c9.2ad4f8"
  369.             ]
  370.         ]
  371.     },
  372.     {
  373.         "id": "fae73554750aae18",
  374.         "type": "actionflows_in",
  375.         "z": "1701a0.212bae61",
  376.         "name": "core.npm.require",
  377.         "priority": "50",
  378.         "links": [],
  379.         "scope": "global",
  380.         "x": 154,
  381.         "y": 1012.0000152587891,
  382.         "wires": [
  383.             [
  384.                 "cf8613806abbaad4"
  385.             ]
  386.         ]
  387.     },
  388.     {
  389.         "id": "cf8613806abbaad4",
  390.         "type": "function",
  391.         "z": "1701a0.212bae61",
  392.         "name": "",
  393.         "func": "const moduleName = msg.payload.module;\n//node.warn(moduleName);\n\nif (msg.payload.cached !== true) {\n    const cacheKey = global.get('require')(\"path\").resolve(moduleName);\n    node.warn(\"Remove from require cache\");\n    \n    // odstranit z cache\n    delete global.get('require').cache[cacheKey];\n}\n\nconst mod = global.get('require')(moduleName);\n\n//node.warn(mod);\n\nmsg.payload = mod;\n\nreturn msg;",
  394.         "outputs": 1,
  395.         "noerr": 0,
  396.         "initialize": "",
  397.         "finalize": "",
  398.         "libs": [],
  399.         "x": 362.00000762939453,
  400.         "y": 1012.0000324249268,
  401.         "wires": [
  402.             [
  403.                 "6ba1b30a2bda7e67"
  404.             ]
  405.         ]
  406.     },
  407.     {
  408.         "id": "0ac4b279ed200deb",
  409.         "type": "comment",
  410.         "z": "1701a0.212bae61",
  411.         "name": "require",
  412.         "info": "",
  413.         "x": 97.80001831054688,
  414.         "y": 929.0000152587891,
  415.         "wires": []
  416.     },
  417.     {
  418.         "id": "6ba1b30a2bda7e67",
  419.         "type": "actionflows_out",
  420.         "z": "1701a0.212bae61",
  421.         "name": "action out",
  422.         "links": [],
  423.         "x": 549.0000076293945,
  424.         "y": 1017.0000324249268,
  425.         "wires": []
  426.     },
  427.     {
  428.         "id": "b814d00e3ff56199",
  429.         "type": "inject",
  430.         "z": "1701a0.212bae61",
  431.         "name": "",
  432.         "props": [
  433.             {
  434.                 "p": "payload"
  435.             },
  436.             {
  437.                 "p": "topic",
  438.                 "vt": "str"
  439.             }
  440.         ],
  441.         "repeat": "",
  442.         "crontab": "",
  443.         "once": false,
  444.         "onceDelay": 0.1,
  445.         "topic": "",
  446.         "payload": "",
  447.         "payloadType": "date",
  448.         "x": 228.0000228881836,
  449.         "y": 1104.9999752044678,
  450.         "wires": [
  451.             [
  452.                 "f82ab7016c2e1cd6"
  453.             ]
  454.         ]
  455.     },
  456.     {
  457.         "id": "f82ab7016c2e1cd6",
  458.         "type": "function",
  459.         "z": "1701a0.212bae61",
  460.         "name": "require test",
  461.         "func": "\nconst af = global.get('actionflows');\n\nconst batterySocPredictionEngine = (await af.invoke('core.npm.require', {payload: {\n    module: '/home/gibo/dev/misc/pv/battery_soc_prediction/engine',\n}})).payload;\n\nnode.warn(batterySocPredictionEngine)\n",
  462.         "outputs": 1,
  463.         "noerr": 0,
  464.         "initialize": "",
  465.         "finalize": "",
  466.         "libs": [],
  467.         "x": 433.0000228881836,
  468.         "y": 1111.9999732971191,
  469.         "wires": [
  470.             []
  471.         ]
  472.     },
  473.     {
  474.         "id": "11435707ad5f8b4a",
  475.         "type": "actionflows_in",
  476.         "z": "1701a0.212bae61",
  477.         "name": "rdns",
  478.         "priority": "50",
  479.         "links": [],
  480.         "scope": "global",
  481.         "x": 139.00003051757812,
  482.         "y": 1343.4001550674438,
  483.         "wires": [
  484.             [
  485.                 "f96995170da63cfd"
  486.             ]
  487.         ]
  488.     },
  489.     {
  490.         "id": "15212355ac8771c0",
  491.         "type": "actionflows_out",
  492.         "z": "1701a0.212bae61",
  493.         "name": "action out",
  494.         "links": [],
  495.         "x": 1050.0001373291016,
  496.         "y": 1403.400200843811,
  497.         "wires": []
  498.     },
  499.     {
  500.         "id": "a65e007551310504",
  501.         "type": "comment",
  502.         "z": "1701a0.212bae61",
  503.         "name": "rdns",
  504.         "info": "",
  505.         "x": 109.00003051757812,
  506.         "y": 1274.4001531600952,
  507.         "wires": []
  508.     },
  509.     {
  510.         "id": "2a70b1b3c0d28675",
  511.         "type": "exec",
  512.         "z": "1701a0.212bae61",
  513.         "command": "host",
  514.         "addpay": "payload",
  515.         "append": "",
  516.         "useSpawn": "false",
  517.         "timer": "",
  518.         "winHide": false,
  519.         "oldrc": false,
  520.         "name": "",
  521.         "x": 545.0000534057617,
  522.         "y": 1324.4003133773804,
  523.         "wires": [
  524.             [
  525.                 "b5fc5eb91f956558"
  526.             ],
  527.             [],
  528.             []
  529.         ]
  530.     },
  531.     {
  532.         "id": "e0958720beffd280",
  533.         "type": "inject",
  534.         "z": "1701a0.212bae61",
  535.         "name": "",
  536.         "props": [
  537.             {
  538.                 "p": "payload"
  539.             },
  540.             {
  541.                 "p": "topic",
  542.                 "vt": "str"
  543.             }
  544.         ],
  545.         "repeat": "",
  546.         "crontab": "",
  547.         "once": false,
  548.         "onceDelay": 0.1,
  549.         "topic": "",
  550.         "payload": "192.168.1.530",
  551.         "payloadType": "str",
  552.         "x": 193.00003051757812,
  553.         "y": 1410.80020236969,
  554.         "wires": [
  555.             [
  556.                 "f96995170da63cfd"
  557.             ]
  558.         ]
  559.     },
  560.     {
  561.         "id": "07a78a1b984453fa",
  562.         "type": "function",
  563.         "z": "1701a0.212bae61",
  564.         "name": "function 1",
  565.         "func": "return msg;",
  566.         "outputs": 1,
  567.         "noerr": 0,
  568.         "initialize": "",
  569.         "finalize": "",
  570.         "libs": [],
  571.         "x": 888.0001831054688,
  572.         "y": 1351.8002157211304,
  573.         "wires": [
  574.             [
  575.                 "15212355ac8771c0",
  576.                 "6f665c5d1f60360f"
  577.             ]
  578.         ]
  579.     },
  580.     {
  581.         "id": "8c9fdf9b82fd9e97",
  582.         "type": "inject",
  583.         "z": "1701a0.212bae61",
  584.         "name": "",
  585.         "props": [
  586.             {
  587.                 "p": "payload"
  588.             },
  589.             {
  590.                 "p": "topic",
  591.                 "vt": "str"
  592.             }
  593.         ],
  594.         "repeat": "",
  595.         "crontab": "",
  596.         "once": false,
  597.         "onceDelay": 0.1,
  598.         "topic": "",
  599.         "payload": "192.168.1.53",
  600.         "payloadType": "str",
  601.         "x": 193.00003051757812,
  602.         "y": 1449.8001794815063,
  603.         "wires": [
  604.             [
  605.                 "f96995170da63cfd"
  606.             ]
  607.         ]
  608.     },
  609.     {
  610.         "id": "6f665c5d1f60360f",
  611.         "type": "debug",
  612.         "z": "1701a0.212bae61",
  613.         "name": "debug 2",
  614.         "active": false,
  615.         "tosidebar": true,
  616.         "console": false,
  617.         "tostatus": false,
  618.         "complete": "false",
  619.         "statusVal": "",
  620.         "statusType": "auto",
  621.         "x": 1040.000135421753,
  622.         "y": 1320.600079536438,
  623.         "wires": []
  624.     },
  625.     {
  626.         "id": "b6b7b286ee400cfe",
  627.         "type": "comment",
  628.         "z": "1701a0.212bae61",
  629.         "name": "Events",
  630.         "info": "",
  631.         "x": 105.20009994506836,
  632.         "y": 1840.1998567581177,
  633.         "wires": []
  634.     },
  635.     {
  636.         "id": "3adf467b89fa2175",
  637.         "type": "debug",
  638.         "z": "1701a0.212bae61",
  639.         "name": "debug 16",
  640.         "active": false,
  641.         "tosidebar": true,
  642.         "console": false,
  643.         "tostatus": false,
  644.         "complete": "true",
  645.         "targetType": "full",
  646.         "statusVal": "",
  647.         "statusType": "auto",
  648.         "x": 424.2001266479492,
  649.         "y": 1936.1999831199646,
  650.         "wires": []
  651.     },
  652.     {
  653.         "id": "4de3dc413c2e28fa",
  654.         "type": "inject",
  655.         "z": "1701a0.212bae61",
  656.         "name": "event test1",
  657.         "props": [
  658.             {
  659.                 "p": "payload"
  660.             },
  661.             {
  662.                 "p": "topic",
  663.                 "vt": "str"
  664.             },
  665.             {
  666.                 "p": "req",
  667.                 "v": "{\"headers\":{\"x-forwarded-for\":\"192.168.1.150\",\"user-agent\":\"test-browser\"}}",
  668.                 "vt": "json"
  669.             }
  670.         ],
  671.         "repeat": "",
  672.         "crontab": "",
  673.         "once": false,
  674.         "onceDelay": 0.1,
  675.         "topic": "",
  676.         "payload": "{\"event\":\"test1\",\"hostname\":\"smarthouse-controller-test\",\"whatever\":\"some value\"}",
  677.         "payloadType": "json",
  678.         "x": 267.2001304626465,
  679.         "y": 2139.1997027397156,
  680.         "wires": [
  681.             [
  682.                 "60ab4fa0b242af59"
  683.             ]
  684.         ]
  685.     },
  686.     {
  687.         "id": "1ed0a31091c0e916",
  688.         "type": "sub",
  689.         "z": "1701a0.212bae61",
  690.         "name": "core.onEvent",
  691.         "topic": "core.onEvent",
  692.         "x": 265.2000961303711,
  693.         "y": 2211.1997051239014,
  694.         "wires": [
  695.             [
  696.                 "2695547be526d5ae"
  697.             ]
  698.         ]
  699.     },
  700.     {
  701.         "id": "5dba9ec86bebf04c",
  702.         "type": "comment",
  703.         "z": "1701a0.212bae61",
  704.         "name": "test pub/sub",
  705.         "info": "",
  706.         "x": 225.2000617980957,
  707.         "y": 2102.199701309204,
  708.         "wires": []
  709.     },
  710.     {
  711.         "id": "2695547be526d5ae",
  712.         "type": "debug",
  713.         "z": "1701a0.212bae61",
  714.         "name": "debug 17",
  715.         "active": false,
  716.         "tosidebar": true,
  717.         "console": false,
  718.         "tostatus": false,
  719.         "complete": "false",
  720.         "statusVal": "",
  721.         "statusType": "auto",
  722.         "x": 438.2000961303711,
  723.         "y": 2208.1997051239014,
  724.         "wires": []
  725.     },
  726.     {
  727.         "id": "ed413e8b3fc6a9eb",
  728.         "type": "sub",
  729.         "z": "1701a0.212bae61",
  730.         "name": "core.onEvent/smarthouse-controller-test",
  731.         "topic": "core.onEvent/smarthouse-controller-test",
  732.         "x": 353.2000732421875,
  733.         "y": 2248.1996173858643,
  734.         "wires": [
  735.             [
  736.                 "61c83c27abc6bd80"
  737.             ]
  738.         ]
  739.     },
  740.     {
  741.         "id": "61c83c27abc6bd80",
  742.         "type": "debug",
  743.         "z": "1701a0.212bae61",
  744.         "name": "debug 18",
  745.         "active": false,
  746.         "tosidebar": true,
  747.         "console": false,
  748.         "tostatus": false,
  749.         "complete": "false",
  750.         "statusVal": "",
  751.         "statusType": "auto",
  752.         "x": 600.2001266479492,
  753.         "y": 2248.1997051239014,
  754.         "wires": []
  755.     },
  756.     {
  757.         "id": "0dee66451735a7ca",
  758.         "type": "sub",
  759.         "z": "1701a0.212bae61",
  760.         "name": "core.onEvent/smarthouse-controller-test/test1",
  761.         "topic": "core.onEvent/smarthouse-controller-test/test1",
  762.         "x": 366.2000732421875,
  763.         "y": 2286.1996173858643,
  764.         "wires": [
  765.             [
  766.                 "3391adc015b6a8d8"
  767.             ]
  768.         ]
  769.     },
  770.     {
  771.         "id": "3391adc015b6a8d8",
  772.         "type": "debug",
  773.         "z": "1701a0.212bae61",
  774.         "name": "debug 19",
  775.         "active": false,
  776.         "tosidebar": true,
  777.         "console": false,
  778.         "tostatus": false,
  779.         "complete": "false",
  780.         "statusVal": "",
  781.         "statusType": "auto",
  782.         "x": 640.2001266479492,
  783.         "y": 2284.1997051239014,
  784.         "wires": []
  785.     },
  786.     {
  787.         "id": "d81871d2db0e359d",
  788.         "type": "sub",
  789.         "z": "1701a0.212bae61",
  790.         "name": "core.onEvent/smarthouse-controller-test/test2",
  791.         "topic": "core.onEvent/smarthouse-controller-test/test2",
  792.         "x": 366.2000732421875,
  793.         "y": 2323.1996173858643,
  794.         "wires": [
  795.             [
  796.                 "3c1a0e64a8c7ac5d"
  797.             ]
  798.         ]
  799.     },
  800.     {
  801.         "id": "3c1a0e64a8c7ac5d",
  802.         "type": "debug",
  803.         "z": "1701a0.212bae61",
  804.         "name": "debug 20",
  805.         "active": false,
  806.         "tosidebar": true,
  807.         "console": false,
  808.         "tostatus": false,
  809.         "complete": "false",
  810.         "statusVal": "",
  811.         "statusType": "auto",
  812.         "x": 640.2001266479492,
  813.         "y": 2321.1997051239014,
  814.         "wires": []
  815.     },
  816.     {
  817.         "id": "e7e3b7c733934777",
  818.         "type": "inject",
  819.         "z": "1701a0.212bae61",
  820.         "name": "event test2",
  821.         "props": [
  822.             {
  823.                 "p": "payload"
  824.             },
  825.             {
  826.                 "p": "topic",
  827.                 "vt": "str"
  828.             },
  829.             {
  830.                 "p": "req",
  831.                 "v": "{\"headers\":{\"x-forwarded-for\":\"192.168.1.150\",\"user-agent\":\"test-browser\"}}",
  832.                 "vt": "json"
  833.             }
  834.         ],
  835.         "repeat": "",
  836.         "crontab": "",
  837.         "once": false,
  838.         "onceDelay": 0.1,
  839.         "topic": "",
  840.         "payload": "{\"event\":\"test2\",\"hostname\":\"smarthouse-controller-test\",\"whatever\":\"some value\"}",
  841.         "payloadType": "json",
  842.         "x": 269.20009994506836,
  843.         "y": 2173.1996154785156,
  844.         "wires": [
  845.             [
  846.                 "60ab4fa0b242af59"
  847.             ]
  848.         ]
  849.     },
  850.     {
  851.         "id": "eda1cd9c3423df9a",
  852.         "type": "function",
  853.         "z": "1701a0.212bae61",
  854.         "name": "send to coreserver and publish",
  855.         "func": "const af = global.get('actionflows');\n\n// vytahnout o jakou udalost jde a jeji atributy\nconst {event, ...eventAttributes} = msg.payload;\n\nif (!event) return;\n\n// vytahnout ip adresu kdo to poslal\nconst clientIp = msg.req.headers['x-forwarded-for'] || msg.req.connection.remoteAddress;\n//node.warn(clientIp);\n\n// zjistit reverzni dns zaznam\nconst resMsg_rdns = await af.invoke('rdns', {payload: clientIp});\nconst remoteAddressHost = resMsg_rdns.payload[0];\n//node.warn(resMsg_rdns);\n//return;\n\n\n// odeslat do coreserveru\nconst clientAttributes = {\n    remoteAddress: {\n        ip: clientIp,\n        host: remoteAddressHost,\n    },\n    userAgent: msg.req.headers['user-agent'],\n};\nconst resMsg_notify = await af.invoke('core.rpc', {\n    method: 'notification.notify',\n    payload: [event, eventAttributes, clientAttributes],\n});\n//node.warn(resMsg_notify);\n\n\n// publish\n// odeslat event v nekolika podobach\n// core.onEvent\n// core.onEvent/hostname\n// core.onEvent/real-hostname-from-rdns\n// core.onEvent/hostname/event\n// core.onEvent/real-hostname-from-rdns/event\n\n// posbirat varianty\nconst eventVariants = [];\n\n// odeslat jako obecnou udalost\neventVariants.push(\"core.onEvent\");\n\nfor (const hostname of [msg.payload.hostname, remoteAddressHost]) {\n    const eventParts = [\"core.onEvent\"];\n\n    if (hostname) {\n        eventParts.push(hostname);\n    }\n\n    eventParts.push(event);\n\n    for (let i = 1; i <= eventParts.length; ++i) {\n        const eventVariant = eventParts.slice(0, i).join(\"/\");\n        if (!eventVariants.includes(eventVariant)) {\n            eventVariants.push(eventVariant);\n        }\n    }\n}\n\n// odeslat vsechny varianty\nfor (const eventVariant of eventVariants) {\n    const eventMsg = {\n        topic: eventVariant,\n        payload: {\n            ...msg.payload,\n            _: {\n                client: clientAttributes,\n            },\n        },\n    };\n    //node.warn(eventMsg);\n    const resMsg_publish = await af.invoke('publish', eventMsg);\n}",
  856.         "outputs": 1,
  857.         "noerr": 0,
  858.         "initialize": "",
  859.         "finalize": "",
  860.         "libs": [],
  861.         "x": 500.20018768310547,
  862.         "y": 2030.1997413635254,
  863.         "wires": [
  864.             []
  865.         ]
  866.     },
  867.     {
  868.         "id": "562ad48dd8fa3f91",
  869.         "type": "inject",
  870.         "z": "1701a0.212bae61",
  871.         "name": "event test1",
  872.         "props": [
  873.             {
  874.                 "p": "payload"
  875.             },
  876.             {
  877.                 "p": "topic",
  878.                 "vt": "str"
  879.             },
  880.             {
  881.                 "p": "req",
  882.                 "v": "{\"headers\":{\"x-forwarded-for\":\"192.168.1.150\",\"user-agent\":\"test-browser\"}}",
  883.                 "vt": "json"
  884.             }
  885.         ],
  886.         "repeat": "",
  887.         "crontab": "",
  888.         "once": false,
  889.         "onceDelay": 0.1,
  890.         "topic": "",
  891.         "payload": "{\"event\":\"test1\",\"hostname\":\"smarthouse-controller-test\",\"whatever\":\"some value\"}",
  892.         "payloadType": "json",
  893.         "x": 233.20012283325195,
  894.         "y": 2033.1997413635254,
  895.         "wires": [
  896.             [
  897.                 "eda1cd9c3423df9a"
  898.             ]
  899.         ]
  900.     },
  901.     {
  902.         "id": "be0cc16cf0fc21f0",
  903.         "type": "inject",
  904.         "z": "1701a0.212bae61",
  905.         "name": "test",
  906.         "props": [
  907.             {
  908.                 "p": "payload"
  909.             },
  910.             {
  911.                 "p": "topic",
  912.                 "vt": "str"
  913.             }
  914.         ],
  915.         "repeat": "",
  916.         "crontab": "",
  917.         "once": false,
  918.         "onceDelay": 0.1,
  919.         "topic": "",
  920.         "payload": "",
  921.         "payloadType": "date",
  922.         "x": 208.20005798339844,
  923.         "y": 1561.2000350952148,
  924.         "wires": [
  925.             [
  926.                 "aea3d19f9c6bcba2"
  927.             ]
  928.         ]
  929.     },
  930.     {
  931.         "id": "aea3d19f9c6bcba2",
  932.         "type": "function",
  933.         "z": "1701a0.212bae61",
  934.         "name": "",
  935.         "func": "const af = global.get('actionflows');\n\nconst resMsg = await af.invoke('rdns', { payload: \"192.168.1.150\" });\n\nreturn resMsg;",
  936.         "outputs": 1,
  937.         "noerr": 0,
  938.         "initialize": "",
  939.         "finalize": "",
  940.         "libs": [],
  941.         "x": 386.2000617980957,
  942.         "y": 1568.2000360488892,
  943.         "wires": [
  944.             [
  945.                 "bf634883d51a1f51"
  946.             ]
  947.         ]
  948.     },
  949.     {
  950.         "id": "bf634883d51a1f51",
  951.         "type": "debug",
  952.         "z": "1701a0.212bae61",
  953.         "name": "",
  954.         "active": false,
  955.         "tosidebar": true,
  956.         "console": false,
  957.         "tostatus": false,
  958.         "complete": "false",
  959.         "statusVal": "",
  960.         "statusType": "auto",
  961.         "x": 588.200065612793,
  962.         "y": 1562.2000341415405,
  963.         "wires": []
  964.     },
  965.     {
  966.         "id": "4db0f36a2ab8025a",
  967.         "type": "actionflows_in",
  968.         "z": "1701a0.212bae61",
  969.         "name": "core.raiseEvent",
  970.         "priority": "50",
  971.         "links": [],
  972.         "scope": "global",
  973.         "x": 233.20008087158203,
  974.         "y": 1972.199984073639,
  975.         "wires": [
  976.             [
  977.                 "3adf467b89fa2175",
  978.                 "eda1cd9c3423df9a",
  979.                 "c6a4f82c78c91533"
  980.             ]
  981.         ]
  982.     },
  983.     {
  984.         "id": "c6a4f82c78c91533",
  985.         "type": "actionflows_out",
  986.         "z": "1701a0.212bae61",
  987.         "name": "action out",
  988.         "links": [],
  989.         "x": 427.2002487182617,
  990.         "y": 1979.199984073639,
  991.         "wires": []
  992.     },
  993.     {
  994.         "id": "60ab4fa0b242af59",
  995.         "type": "actionflows",
  996.         "z": "1701a0.212bae61",
  997.         "info": "Describe your action API here.",
  998.         "untilproptype": "num",
  999.         "proptype": "msg",
  1000.         "name": "core.raiseEvent",
  1001.         "prop": "loop",
  1002.         "untilprop": 0,
  1003.         "until": "gt",
  1004.         "loop": "none",
  1005.         "scope": "global",
  1006.         "perf": false,
  1007.         "seq": false,
  1008.         "x": 458.2002754211426,
  1009.         "y": 2151.1997022628784,
  1010.         "wires": [
  1011.             []
  1012.         ]
  1013.     },
  1014.     {
  1015.         "id": "7d2eb2e80ca14650",
  1016.         "type": "comment",
  1017.         "z": "1701a0.212bae61",
  1018.         "name": "process",
  1019.         "info": "",
  1020.         "x": 207.20006561279297,
  1021.         "y": 1889.1999821662903,
  1022.         "wires": []
  1023.     },
  1024.     {
  1025.         "id": "ab6adde9e972fe0d",
  1026.         "type": "actionflows_in",
  1027.         "z": "1701a0.212bae61",
  1028.         "name": "publish",
  1029.         "priority": "50",
  1030.         "links": [],
  1031.         "scope": "global",
  1032.         "x": 174.20005798339844,
  1033.         "y": 1744.1999588012695,
  1034.         "wires": [
  1035.             [
  1036.                 "97f578b595232d19"
  1037.             ]
  1038.         ]
  1039.     },
  1040.     {
  1041.         "id": "97f578b595232d19",
  1042.         "type": "function",
  1043.         "z": "1701a0.212bae61",
  1044.         "name": "",
  1045.         "func": "return msg;",
  1046.         "outputs": 1,
  1047.         "noerr": 0,
  1048.         "initialize": "",
  1049.         "finalize": "",
  1050.         "libs": [],
  1051.         "x": 346.20006561279297,
  1052.         "y": 1747.200038909912,
  1053.         "wires": [
  1054.             [
  1055.                 "3c40152c60cf0012",
  1056.                 "b9dbb2e9b2d7a374"
  1057.             ]
  1058.         ]
  1059.     },
  1060.     {
  1061.         "id": "020b0adad2493ca6",
  1062.         "type": "comment",
  1063.         "z": "1701a0.212bae61",
  1064.         "name": "publish",
  1065.         "info": "",
  1066.         "x": 109.00007247924805,
  1067.         "y": 1689.2000370025635,
  1068.         "wires": []
  1069.     },
  1070.     {
  1071.         "id": "3c40152c60cf0012",
  1072.         "type": "actionflows_out",
  1073.         "z": "1701a0.212bae61",
  1074.         "name": "action out",
  1075.         "links": [],
  1076.         "x": 526.2001571655273,
  1077.         "y": 1760.2000379562378,
  1078.         "wires": []
  1079.     },
  1080.     {
  1081.         "id": "b9dbb2e9b2d7a374",
  1082.         "type": "pub",
  1083.         "z": "1701a0.212bae61",
  1084.         "name": "",
  1085.         "topic": "",
  1086.         "message": "",
  1087.         "x": 520.2000350952148,
  1088.         "y": 1719.2000370025635,
  1089.         "wires": []
  1090.     },
  1091.     {
  1092.         "id": "dd1985b2c3c19e44",
  1093.         "type": "function",
  1094.         "z": "1701a0.212bae61",
  1095.         "name": "graphize",
  1096.         "func": "const rows = msg.payload;\n\nif (rows.length == 0) {\n    return [];\n}\n\n// pokusime se najit v prvni radce, ktery sloupec je ten s datumem\nconst firstRow = rows[0];\n// const columnNames = Object.keys(firstRow);\nconst columnNamesMap = new Map();\nfor (const row of rows) {\n    for (const columnName in row) {\n        columnNamesMap.set(columnName, null);\n    }\n}\nconst columnNames = [...columnNamesMap.keys()];\n// node.warn(columnNames);\n\nlet dateColumnName = null;\nfor (const columnName of columnNames) {\n    const val = firstRow[columnName];\n    if (columnName == 'date') {\n        dateColumnName = columnName;\n        break;\n    }else if (columnName == 'timestamp') {\n        dateColumnName = columnName;\n        break;\n    } else if (typeof val === 'string' && !isNaN(Date.parse(val))) {\n        dateColumnName = columnName;\n        break;\n    } else if (typeof val === 'number' && val >= 946684800000 && val <= 4102444800000) {\n        dateColumnName = columnName;\n        break;\n    }\n}\n//node.warn(dateColumnName);\n\nif (dateColumnName === null) {\n    node.error(\"Unable to recognize date column\");\n    return [];\n}\n\nconst firstRowDate = firstRow[dateColumnName];\n// prevest na timestamp\nif (typeof firstRowDate === 'string' && !isNaN(Date.parse(firstRowDate))) {\n    for (const row of rows) {\n        row[dateColumnName] = Date.parse(row[dateColumnName]);\n    }\n}\n\nconst seriesNames = [];\nfor (const columnName of columnNames) {\n    if (columnName !== dateColumnName) {\n        seriesNames.push(columnName);\n    }\n}\n\nconst seriesData = [];\nfor (const serieName of seriesNames) {\n    let data = [];\n\n    for (const row of rows) {\n        if (dateColumnName in row) {\n            data.push({\n                x: row[dateColumnName],\n                y: row[serieName],\n            });\n        }\n    }\n\n    seriesData.push(data);\n}\n\n\nmsg.payload = [\n    {\n        \"series\": seriesNames,\n        \"data\": seriesData,\n        \"labels\": [\"\"]\n    }\n]\n\nreturn msg;",
  1097.         "outputs": 1,
  1098.         "noerr": 0,
  1099.         "initialize": "",
  1100.         "finalize": "",
  1101.         "libs": [],
  1102.         "x": 497.2000045776367,
  1103.         "y": 2507.199867248535,
  1104.         "wires": [
  1105.             [
  1106.                 "5c157950e238dfb0"
  1107.             ]
  1108.         ]
  1109.     },
  1110.     {
  1111.         "id": "80c642d757d18206",
  1112.         "type": "comment",
  1113.         "z": "1701a0.212bae61",
  1114.         "name": "Dashboard utils",
  1115.         "info": "",
  1116.         "x": 177.20000839233398,
  1117.         "y": 2435.1998653411865,
  1118.         "wires": []
  1119.     },
  1120.     {
  1121.         "id": "ce6fb6cfd3385f9b",
  1122.         "type": "actionflows_in",
  1123.         "z": "1701a0.212bae61",
  1124.         "name": "core.dashboard.graphize",
  1125.         "priority": "50",
  1126.         "links": [],
  1127.         "scope": "global",
  1128.         "x": 279.1999969482422,
  1129.         "y": 2506.199951171875,
  1130.         "wires": [
  1131.             [
  1132.                 "dd1985b2c3c19e44"
  1133.             ]
  1134.         ]
  1135.     },
  1136.     {
  1137.         "id": "5c157950e238dfb0",
  1138.         "type": "actionflows_out",
  1139.         "z": "1701a0.212bae61",
  1140.         "name": "action out",
  1141.         "links": [],
  1142.         "x": 733.2000350952148,
  1143.         "y": 2508.199867248535,
  1144.         "wires": []
  1145.     },
  1146.     {
  1147.         "id": "adf3e932b79f5f3e",
  1148.         "type": "inject",
  1149.         "z": "1701a0.212bae61",
  1150.         "name": "test",
  1151.         "props": [
  1152.             {
  1153.                 "p": "payload"
  1154.             },
  1155.             {
  1156.                 "p": "topic",
  1157.                 "vt": "str"
  1158.             }
  1159.         ],
  1160.         "repeat": "",
  1161.         "crontab": "",
  1162.         "once": false,
  1163.         "onceDelay": 0.1,
  1164.         "topic": "",
  1165.         "payload": "",
  1166.         "payloadType": "date",
  1167.         "x": 234.19997787475586,
  1168.         "y": 2621.1999502182007,
  1169.         "wires": [
  1170.             [
  1171.                 "e6b03731ae6e9708"
  1172.             ]
  1173.         ]
  1174.     },
  1175.     {
  1176.         "id": "7d867d765bd6bbd4",
  1177.         "type": "debug",
  1178.         "z": "1701a0.212bae61",
  1179.         "name": "",
  1180.         "active": true,
  1181.         "tosidebar": true,
  1182.         "console": false,
  1183.         "tostatus": false,
  1184.         "complete": "false",
  1185.         "statusVal": "",
  1186.         "statusType": "auto",
  1187.         "x": 847.2000389099121,
  1188.         "y": 2630.199869155884,
  1189.         "wires": []
  1190.     },
  1191.     {
  1192.         "id": "e6b03731ae6e9708",
  1193.         "type": "function",
  1194.         "z": "1701a0.212bae61",
  1195.         "name": "",
  1196.         "func": "msg.payload = [\n    {\n        \"xdate\": \"2022-12-31T23:00:00.000Z\",\n        \"imported_kwh\": 29.35,\n        \"exported_kwh\": 1.13\n    },\n    {\n        \"xdate\": \"2023-01-01T23:00:00.000Z\",\n        \"imported_kwh\": 55.46,\n        \"exported_kwh\": 2.21\n    },\n    {\n        \"xdate\": \"2023-01-02T23:00:00.000Z\",\n        \"imported_kwh\": 80.53,\n        \"exported_kwh\": 2.6\n    },\n];\n\nreturn msg;\n",
  1197.         "outputs": 1,
  1198.         "noerr": 0,
  1199.         "initialize": "",
  1200.         "finalize": "",
  1201.         "libs": [],
  1202.         "x": 412.1999816894531,
  1203.         "y": 2628.199951171875,
  1204.         "wires": [
  1205.             [
  1206.                 "bc384afe885770b1"
  1207.             ]
  1208.         ]
  1209.     },
  1210.     {
  1211.         "id": "bc384afe885770b1",
  1212.         "type": "actionflows",
  1213.         "z": "1701a0.212bae61",
  1214.         "info": "Describe your action API here.",
  1215.         "untilproptype": "num",
  1216.         "proptype": "msg",
  1217.         "name": "core.dashboard.graphize",
  1218.         "prop": "loop",
  1219.         "untilprop": 0,
  1220.         "until": "gt",
  1221.         "loop": "none",
  1222.         "scope": "global",
  1223.         "perf": false,
  1224.         "seq": false,
  1225.         "x": 631.2000312805176,
  1226.         "y": 2631.199870109558,
  1227.         "wires": [
  1228.             [
  1229.                 "7d867d765bd6bbd4"
  1230.             ]
  1231.         ]
  1232.     },
  1233.     {
  1234.         "id": "e3bffbff9e2d3090",
  1235.         "type": "comment",
  1236.         "z": "1701a0.212bae61",
  1237.         "name": "DNS cache",
  1238.         "info": "",
  1239.         "x": 1128.199951171875,
  1240.         "y": 584.2000122070312,
  1241.         "wires": []
  1242.     },
  1243.     {
  1244.         "id": "71159e444cc2566e",
  1245.         "type": "function",
  1246.         "z": "1701a0.212bae61",
  1247.         "name": "patch dns.lookup",
  1248.         "func": "// funkce nahradi vestavenou funkci dns.lookup, tak aby vsechny sitove requesty\n// mohli vyuzivat dns cache a jeden pozadavek neblokoval ostatni napr. v momente, kdy\n// vypadne internet a nelze resolvit verejne domeny, ale vnitrni domeny na lokalni siti by\n// resolvit sly. Nefunkcnosti interetu by bylo ale zablokovani vsechno.\n\nlet originalLookup = flow.get(\"dns-originalLookup\");\nif (!originalLookup) {\n    originalLookup = dns.lookup;\n    flow.set(\"dns-originalLookup\", originalLookup);\n}\n\nlet cache = flow.get(\"dns-cache\");\nif (!cache) {\n    cache = new Map();\n    flow.set(\"dns-cache\", cache);\n}\n\n// @ts-ignore\ndns.lookup = function (domain, family, callback) {\n    //node.warn(`DNS Lookup for: ${domain}`);\n\n    if (cache.has(domain)) {\n        const cachedResult = cache.get(domain);\n        if (cachedResult[0] === null) {\n            callback(...cachedResult);\n        }\n    }else {\n        originalLookup(domain, family, (...result) => {\n            cache.set(domain, result);\n            callback(...result);\n        });\n    }\n};\n\n",
  1249.         "outputs": 1,
  1250.         "noerr": 0,
  1251.         "initialize": "",
  1252.         "finalize": "",
  1253.         "libs": [
  1254.             {
  1255.                 "var": "dns",
  1256.                 "module": "dns"
  1257.             }
  1258.         ],
  1259.         "x": 1456.200050354004,
  1260.         "y": 644.2000370025635,
  1261.         "wires": [
  1262.             []
  1263.         ]
  1264.     },
  1265.     {
  1266.         "id": "ba2e12c10bfac604",
  1267.         "type": "inject",
  1268.         "z": "1701a0.212bae61",
  1269.         "name": "",
  1270.         "props": [
  1271.             {
  1272.                 "p": "payload"
  1273.             },
  1274.             {
  1275.                 "p": "topic",
  1276.                 "vt": "str"
  1277.             }
  1278.         ],
  1279.         "repeat": "",
  1280.         "crontab": "",
  1281.         "once": true,
  1282.         "onceDelay": 0.1,
  1283.         "topic": "",
  1284.         "payload": "",
  1285.         "payloadType": "date",
  1286.         "x": 1227.2000427246094,
  1287.         "y": 644.2000370025635,
  1288.         "wires": [
  1289.             [
  1290.                 "71159e444cc2566e"
  1291.             ]
  1292.         ]
  1293.     },
  1294.     {
  1295.         "id": "f96995170da63cfd",
  1296.         "type": "function",
  1297.         "z": "1701a0.212bae61",
  1298.         "name": "function 42",
  1299.         "func": "msg.ip = msg.payload;\n\nconst cache = flow.get(\"rdns-cache\");\nif (cache && cache.has(msg.ip)) {\n    msg.payload = cache.get(msg.ip);\n    return [null, msg];\n}else {\n    return [msg, null];\n}\n\n",
  1300.         "outputs": 2,
  1301.         "noerr": 0,
  1302.         "initialize": "",
  1303.         "finalize": "",
  1304.         "libs": [],
  1305.         "x": 377.20003509521484,
  1306.         "y": 1354.2001180648804,
  1307.         "wires": [
  1308.             [
  1309.                 "2a70b1b3c0d28675"
  1310.             ],
  1311.             [
  1312.                 "c3b5d0f22d608734"
  1313.             ]
  1314.         ]
  1315.     },
  1316.     {
  1317.         "id": "b5fc5eb91f956558",
  1318.         "type": "function",
  1319.         "z": "1701a0.212bae61",
  1320.         "name": "function 43",
  1321.         "func": "const match = msg.payload.trim().match(/.*pointer (.+?)\\.?$/);\n//node.warn(match);\nif (match) {\n    const hostname = match[1];\n    msg.payload = [hostname];\n}else {\n    msg.payload = [];\n}\n\nlet cache = flow.get(\"rdns-cache\");\nif (!cache) {\n    cache = new Map();\n    flow.set(\"rdns-cache\", cache);\n}\ncache.set(msg.ip, msg.payload);\n\nreturn msg;",
  1322.         "outputs": 1,
  1323.         "noerr": 0,
  1324.         "initialize": "",
  1325.         "finalize": "",
  1326.         "libs": [],
  1327.         "x": 718.2001914978027,
  1328.         "y": 1306.2001180648804,
  1329.         "wires": [
  1330.             [
  1331.                 "07a78a1b984453fa"
  1332.             ]
  1333.         ]
  1334.     },
  1335.     {
  1336.         "id": "c3b5d0f22d608734",
  1337.         "type": "function",
  1338.         "z": "1701a0.212bae61",
  1339.         "name": "function 44",
  1340.         "func": "\nreturn msg;",
  1341.         "outputs": 1,
  1342.         "noerr": 0,
  1343.         "initialize": "",
  1344.         "finalize": "",
  1345.         "libs": [],
  1346.         "x": 582.200065612793,
  1347.         "y": 1391.2001190185547,
  1348.         "wires": [
  1349.             [
  1350.                 "07a78a1b984453fa"
  1351.             ]
  1352.         ]
  1353.     },
  1354.     {
  1355.         "id": "52493f9c1ebdeb7c",
  1356.         "type": "actionflows_in",
  1357.         "z": "1701a0.212bae61",
  1358.         "name": "core.prometheus.query",
  1359.         "priority": "50",
  1360.         "links": [],
  1361.         "scope": "global",
  1362.         "x": 221.2000274658203,
  1363.         "y": 2841.199951171875,
  1364.         "wires": [
  1365.             [
  1366.                 "47823b1d51969111"
  1367.             ]
  1368.         ]
  1369.     },
  1370.     {
  1371.         "id": "5b6dd088c1df14bc",
  1372.         "type": "comment",
  1373.         "z": "1701a0.212bae61",
  1374.         "name": "query prometheus",
  1375.         "info": "",
  1376.         "x": 186.00003051757812,
  1377.         "y": 2763.199869155884,
  1378.         "wires": []
  1379.     },
  1380.     {
  1381.         "id": "20ba8d984f349233",
  1382.         "type": "actionflows_out",
  1383.         "z": "1701a0.212bae61",
  1384.         "name": "action out",
  1385.         "links": [],
  1386.         "x": 685.2000694274902,
  1387.         "y": 2845.1998710632324,
  1388.         "wires": []
  1389.     },
  1390.     {
  1391.         "id": "47823b1d51969111",
  1392.         "type": "function",
  1393.         "z": "1701a0.212bae61",
  1394.         "name": "function 53",
  1395.         "func": "const prom = new prometheusQuery.PrometheusDriver({\n    endpoint: \"http://vs-monitoring-prometheus-test:9090/\",\n    baseURL: \"/api/v1\" // default value\n});\n\nconst query = msg.payload;\nconst res = await prom.instantQuery(query);\n\nmsg.payload = res.result;\n\nreturn msg;",
  1396.         "outputs": 1,
  1397.         "noerr": 0,
  1398.         "initialize": "",
  1399.         "finalize": "",
  1400.         "libs": [
  1401.             {
  1402.                 "var": "prometheusQuery",
  1403.                 "module": "prometheus-query"
  1404.             }
  1405.         ],
  1406.         "x": 478.20003509521484,
  1407.         "y": 2843.1998710632324,
  1408.         "wires": [
  1409.             [
  1410.                 "20ba8d984f349233"
  1411.             ]
  1412.         ]
  1413.     },
  1414.     {
  1415.         "id": "ad54a324eb907ae9",
  1416.         "type": "comment",
  1417.         "z": "1701a0.212bae61",
  1418.         "name": "humanize",
  1419.         "info": "",
  1420.         "x": 154.2000389099121,
  1421.         "y": 3072.199872970581,
  1422.         "wires": []
  1423.     },
  1424.     {
  1425.         "id": "a04b02b8d992a42c",
  1426.         "type": "actionflows_in",
  1427.         "z": "1701a0.212bae61",
  1428.         "name": "core.humanize",
  1429.         "priority": "50",
  1430.         "links": [],
  1431.         "scope": "global",
  1432.         "x": 192.4000244140625,
  1433.         "y": 3130.200033187866,
  1434.         "wires": [
  1435.             [
  1436.                 "fbc8e50b81b20225"
  1437.             ]
  1438.         ]
  1439.     },
  1440.     {
  1441.         "id": "fbc8e50b81b20225",
  1442.         "type": "function",
  1443.         "z": "1701a0.212bae61",
  1444.         "name": "function 54",
  1445.         "func": "const type = msg.payload.type;\nlet humanizedValue = '';\n\nif (type == \"timeDelta\") {\n    const value = msg.payload.value;\n    if (value < 60) {\n        humanizedValue = `${Math.round(value)}s`;\n    } else if (value < 3600) {\n        humanizedValue = `${Math.round(value / 60)}m`;\n    } else if (value < 3600 * 24) {\n        humanizedValue = `${Math.round(value / 3600)}h`;\n    } else {\n        humanizedValue = `${Math.round(value / (3600 * 24))}d`;\n    }\n}else {\n    node.warn(`Unknown type ${type} for humanization`);\n    return;\n}\n\nmsg.payload = humanizedValue;\nreturn msg;",
  1446.         "outputs": 1,
  1447.         "noerr": 0,
  1448.         "initialize": "",
  1449.         "finalize": "",
  1450.         "libs": [
  1451.             {
  1452.                 "var": "prometheusQuery",
  1453.                 "module": "prometheus-query"
  1454.             }
  1455.         ],
  1456.         "x": 403.40001678466797,
  1457.         "y": 3129.199872970581,
  1458.         "wires": [
  1459.             [
  1460.                 "c1e798de62ae6019"
  1461.             ]
  1462.         ]
  1463.     },
  1464.     {
  1465.         "id": "c1e798de62ae6019",
  1466.         "type": "actionflows_out",
  1467.         "z": "1701a0.212bae61",
  1468.         "name": "action out",
  1469.         "links": [],
  1470.         "x": 609.4000816345215,
  1471.         "y": 3128.1998739242554,
  1472.         "wires": []
  1473.     },
  1474.     {
  1475.         "id": "e95f83f6a8b66716",
  1476.         "type": "inject",
  1477.         "z": "1701a0.212bae61",
  1478.         "name": "",
  1479.         "props": [
  1480.             {
  1481.                 "p": "payload"
  1482.             },
  1483.             {
  1484.                 "p": "topic",
  1485.                 "vt": "str"
  1486.             }
  1487.         ],
  1488.         "repeat": "",
  1489.         "crontab": "",
  1490.         "once": true,
  1491.         "onceDelay": 0.1,
  1492.         "topic": "",
  1493.         "payload": "",
  1494.         "payloadType": "date",
  1495.         "x": 1232.199951171875,
  1496.         "y": 717.2000122070312,
  1497.         "wires": [
  1498.             [
  1499.                 "b539551d98fd2e4d"
  1500.             ]
  1501.         ]
  1502.     },
  1503.     {
  1504.         "id": "b539551d98fd2e4d",
  1505.         "type": "function",
  1506.         "z": "1701a0.212bae61",
  1507.         "name": "clear dns cache",
  1508.         "func": "let cache = flow.get(\"dns-cache\");\ncache.clear();",
  1509.         "outputs": 1,
  1510.         "noerr": 0,
  1511.         "initialize": "",
  1512.         "finalize": "",
  1513.         "libs": [
  1514.             {
  1515.                 "var": "dns",
  1516.                 "module": "dns"
  1517.             }
  1518.         ],
  1519.         "x": 1451.1999588012695,
  1520.         "y": 717.2000122070312,
  1521.         "wires": [
  1522.             []
  1523.         ]
  1524.     },
  1525.     {
  1526.         "id": "27650506d3d80146",
  1527.         "type": "comment",
  1528.         "z": "1701a0.212bae61",
  1529.         "name": "test db query",
  1530.         "info": "",
  1531.         "x": 182.20001220703125,
  1532.         "y": 724.2000274658203,
  1533.         "wires": []
  1534.     },
  1535.     {
  1536.         "id": "67930b18cd366dd1",
  1537.         "type": "comment",
  1538.         "z": "1701a0.212bae61",
  1539.         "name": "test require",
  1540.         "info": "",
  1541.         "x": 209.1999969482422,
  1542.         "y": 1061.199966430664,
  1543.         "wires": []
  1544.     },
  1545.     {
  1546.         "id": "376a2b9d68d789f7",
  1547.         "type": "comment",
  1548.         "z": "1701a0.212bae61",
  1549.         "name": "test rdns",
  1550.         "info": "",
  1551.         "x": 191.20000648498535,
  1552.         "y": 1512.2000350952148,
  1553.         "wires": []
  1554.     },
  1555.     {
  1556.         "id": "e5a6e24ba45026e6",
  1557.         "type": "comment",
  1558.         "z": "1701a0.212bae61",
  1559.         "name": "test graphize",
  1560.         "info": "",
  1561.         "x": 228.20000076293945,
  1562.         "y": 2580.199867248535,
  1563.         "wires": []
  1564.     },
  1565.     {
  1566.         "id": "b21773b01f468c38",
  1567.         "type": "function",
  1568.         "z": "1701a0.212bae61",
  1569.         "name": "function 71",
  1570.         "func": "const af = global.get('actionflows');\n\nconst lastActivityBefore = (await af.invoke('core.humanize', {\n    payload: {\n        type: 'timeDelta',\n        value: 7,\n    },\n})).payload;\n\nmsg.payload = lastActivityBefore;\nreturn msg;",
  1571.         "outputs": 1,
  1572.         "noerr": 0,
  1573.         "initialize": "",
  1574.         "finalize": "",
  1575.         "libs": [],
  1576.         "x": 393.20003509521484,
  1577.         "y": 3243.199951171875,
  1578.         "wires": [
  1579.             [
  1580.                 "5e48a8d6481937b3"
  1581.             ]
  1582.         ]
  1583.     },
  1584.     {
  1585.         "id": "6afd6e48a239b4ba",
  1586.         "type": "inject",
  1587.         "z": "1701a0.212bae61",
  1588.         "name": "test",
  1589.         "props": [
  1590.             {
  1591.                 "p": "payload"
  1592.             },
  1593.             {
  1594.                 "p": "topic",
  1595.                 "vt": "str"
  1596.             }
  1597.         ],
  1598.         "repeat": "",
  1599.         "crontab": "",
  1600.         "once": false,
  1601.         "onceDelay": 0.1,
  1602.         "topic": "",
  1603.         "payload": "",
  1604.         "payloadType": "date",
  1605.         "x": 237.2000503540039,
  1606.         "y": 3243.199951171875,
  1607.         "wires": [
  1608.             [
  1609.                 "b21773b01f468c38"
  1610.             ]
  1611.         ]
  1612.     },
  1613.     {
  1614.         "id": "5e48a8d6481937b3",
  1615.         "type": "debug",
  1616.         "z": "1701a0.212bae61",
  1617.         "name": "",
  1618.         "active": true,
  1619.         "tosidebar": true,
  1620.         "console": false,
  1621.         "tostatus": false,
  1622.         "complete": "false",
  1623.         "statusVal": "",
  1624.         "statusType": "auto",
  1625.         "x": 583.2002182006836,
  1626.         "y": 3247.199998855591,
  1627.         "wires": []
  1628.     },
  1629.     {
  1630.         "id": "8dbadab04347ae79",
  1631.         "type": "comment",
  1632.         "z": "1701a0.212bae61",
  1633.         "name": "test humanize",
  1634.         "info": "",
  1635.         "x": 245.2000503540039,
  1636.         "y": 3200.199951171875,
  1637.         "wires": []
  1638.     },
  1639.     {
  1640.         "id": "7284c7d9535da8a2",
  1641.         "type": "function",
  1642.         "z": "1701a0.212bae61",
  1643.         "name": "function 72",
  1644.         "func": "const af = global.get('actionflows');\n\n// vycist zaznamy o uspesnosti ping\nconst res = (await af.invoke('core.prometheus.query', {\n    payload: 'probe_success{job=\"blackbox-ping\"}',\n})).payload;\n\nmsg.payload = res;\nreturn msg;",
  1645.         "outputs": 1,
  1646.         "noerr": 0,
  1647.         "initialize": "",
  1648.         "finalize": "",
  1649.         "libs": [],
  1650.         "x": 397.2000312805176,
  1651.         "y": 2945.1999950408936,
  1652.         "wires": [
  1653.             [
  1654.                 "a2f2164db6be20a7"
  1655.             ]
  1656.         ]
  1657.     },
  1658.     {
  1659.         "id": "b8f5b8b05c41a035",
  1660.         "type": "inject",
  1661.         "z": "1701a0.212bae61",
  1662.         "name": "test",
  1663.         "props": [
  1664.             {
  1665.                 "p": "payload"
  1666.             },
  1667.             {
  1668.                 "p": "topic",
  1669.                 "vt": "str"
  1670.             }
  1671.         ],
  1672.         "repeat": "",
  1673.         "crontab": "",
  1674.         "once": false,
  1675.         "onceDelay": 0.1,
  1676.         "topic": "",
  1677.         "payload": "",
  1678.         "payloadType": "date",
  1679.         "x": 253.20004653930664,
  1680.         "y": 2946.1999950408936,
  1681.         "wires": [
  1682.             [
  1683.                 "7284c7d9535da8a2"
  1684.             ]
  1685.         ]
  1686.     },
  1687.     {
  1688.         "id": "a2f2164db6be20a7",
  1689.         "type": "debug",
  1690.         "z": "1701a0.212bae61",
  1691.         "name": "",
  1692.         "active": true,
  1693.         "tosidebar": true,
  1694.         "console": false,
  1695.         "tostatus": false,
  1696.         "complete": "false",
  1697.         "statusVal": "",
  1698.         "statusType": "auto",
  1699.         "x": 599.2002143859863,
  1700.         "y": 2950.2000427246094,
  1701.         "wires": []
  1702.     },
  1703.     {
  1704.         "id": "528db290d3fdf7d9",
  1705.         "type": "comment",
  1706.         "z": "1701a0.212bae61",
  1707.         "name": "test prometheus",
  1708.         "info": "",
  1709.         "x": 257.2000503540039,
  1710.         "y": 2902.1999473571777,
  1711.         "wires": []
  1712.     },
  1713.     {
  1714.         "id": "36ca1673.3376ea",
  1715.         "type": "jsonrpc-client",
  1716.         "name": "smarthouse-core",
  1717.         "host": "vs-smarthouse",
  1718.         "port": "2004",
  1719.         "connection": "http"
  1720.     },
  1721.     {
  1722.         "id": "76a2023f.8c254c",
  1723.         "type": "MySQLdatabase",
  1724.         "name": "",
  1725.         "host": "mysql.smarthouse.vp.ip.kyrian.cz",
  1726.         "port": "3306",
  1727.         "db": "smarthouse",
  1728.         "tz": "",
  1729.         "charset": ""
  1730.     }
  1731. ]
Advertisement
Add Comment
Please, Sign In to add comment