Created
September 16, 2023 07:24
-
-
Save buglloc/a93405ea786dfa4add584bc926406ffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "c54c0f35b8c1f9e4", | |
"type": "subflow", | |
"name": "no-op", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 80, | |
"y": 60, | |
"wires": [] | |
} | |
], | |
"out": [ | |
{ | |
"x": 140, | |
"y": 60, | |
"wires": [ | |
{ | |
"id": "c54c0f35b8c1f9e4", | |
"port": 0 | |
} | |
] | |
} | |
], | |
"env": [], | |
"meta": {}, | |
"color": "#DDAA99" | |
}, | |
{ | |
"id": "e3a7ecec68d5bbe7", | |
"type": "tab", | |
"label": "V2 USDT (multi) -> Clock", | |
"disabled": true, | |
"info": "", | |
"env": [] | |
}, | |
{ | |
"id": "246d88b9c97d865e", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "format msg", | |
"func": "const thbGreen = 54778;\nconst thbRed = 54777;\nconst rubRed = 54780;\nconst rubGreen = 54781;\n\nmsg.payload = {\n text: `${msg.payload.price.toFixed(2)}`,\n icon: msg.payload.trend == \"up\" ? thbGreen : thbRed,\n};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 570, | |
"y": 220, | |
"wires": [ | |
[ | |
"6e9dd441c55e2f28" | |
] | |
] | |
}, | |
{ | |
"id": "4d9f5e7f9edc8d7b", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "up indicator", | |
"func": "msg.payload = {\n color: msg.payload.trend == \"up\" ? [255, 0, 0] : [0, 0, 0],\n topic: \"awtrix/indicator1\",\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 730, | |
"y": 260, | |
"wires": [ | |
[ | |
"bde307c6a89334f6" | |
] | |
] | |
}, | |
{ | |
"id": "34a057caaa4c6b19", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "down indicator", | |
"func": "msg.payload = {\n color: msg.payload.trend == \"down\" ? [0, 255, 0] : [0, 0, 0],\n topic: \"awtrix/indicator3\",\n}\n\nreturn msg;\n", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 740, | |
"y": 300, | |
"wires": [ | |
[ | |
"e7fb79c126121a2e" | |
] | |
] | |
}, | |
{ | |
"id": "343e5f4ad7e85f53", | |
"type": "subflow:c54c0f35b8c1f9e4", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "", | |
"x": 570, | |
"y": 280, | |
"wires": [ | |
[ | |
"4d9f5e7f9edc8d7b", | |
"34a057caaa4c6b19", | |
"f32e1c1252d374a4" | |
] | |
] | |
}, | |
{ | |
"id": "ae944ca73d558687", | |
"type": "http request", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "fetch adv", | |
"method": "POST", | |
"ret": "obj", | |
"paytoqs": "ignore", | |
"url": "https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"insecureHTTPParser": false, | |
"authType": "", | |
"senderr": false, | |
"headers": [ | |
{ | |
"keyType": "other", | |
"keyValue": "Content-Type", | |
"valueType": "other", | |
"valueValue": "application/json" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "User-Agent", | |
"valueType": "other", | |
"valueValue": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.171 Safari/537.36" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "Origin", | |
"valueType": "other", | |
"valueValue": "https://p2p.binance.com" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "Referer", | |
"valueType": "other", | |
"valueValue": "https://p2p.binance.com/en/trade/TinkoffNew/USDT?fiat=RUB" | |
} | |
], | |
"x": 300, | |
"y": 280, | |
"wires": [ | |
[ | |
"d8257bb07eb13894" | |
] | |
] | |
}, | |
{ | |
"id": "beac65be37a076c9", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "Sell RUB req", | |
"func": "msg.payload = {\n \"fiat\": \"RUB\",\n \"page\": 1,\n \"rows\": 10,\n \"tradeType\": \"BUY\",\n \"asset\": \"USDT\",\n \"countries\": [],\n \"proMerchantAds\": false,\n \"shieldMerchantAds\": false,\n \"publisherType\": null,\n \"payTypes\": [/*\"TinkoffNew\"*/ \"RaiffeisenBank\"],\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 150, | |
"y": 280, | |
"wires": [ | |
[ | |
"ae944ca73d558687" | |
] | |
] | |
}, | |
{ | |
"id": "6d0a7c05195e10da", | |
"type": "inject", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "", | |
"props": [ | |
{ | |
"p": "payload" | |
}, | |
{ | |
"p": "topic", | |
"vt": "str" | |
} | |
], | |
"repeat": "", | |
"crontab": "*/10 0-23 * * *", | |
"once": true, | |
"onceDelay": "1", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"x": 150, | |
"y": 160, | |
"wires": [ | |
[ | |
"afbee77071ea1c6f" | |
] | |
] | |
}, | |
{ | |
"id": "e466494b34213e6f", | |
"type": "trigger-state", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "clock button", | |
"server": "34a16949.b02c86", | |
"version": 2, | |
"exposeToHomeAssistant": false, | |
"haConfig": [ | |
{ | |
"property": "name", | |
"value": "" | |
}, | |
{ | |
"property": "icon", | |
"value": "" | |
} | |
], | |
"entityid": "binary_sensor.awtrix_6ff8b0_button_select", | |
"entityidfiltertype": "exact", | |
"debugenabled": false, | |
"constraints": [ | |
{ | |
"targetType": "this_entity", | |
"targetValue": "", | |
"propertyType": "current_state", | |
"propertyValue": "new_state.state", | |
"comparatorType": "is", | |
"comparatorValueDatatype": "bool", | |
"comparatorValue": "true" | |
} | |
], | |
"inputs": 0, | |
"outputs": 2, | |
"customoutputs": [], | |
"outputinitially": false, | |
"state_type": "habool", | |
"enableInput": false, | |
"x": 150, | |
"y": 100, | |
"wires": [ | |
[ | |
"f19ef6b3350e4947" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "2c4122873c5eb69f", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "format msg", | |
"func": "msg.payload = {\n text: \"##.##\",\n icon: 44159,\n};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 450, | |
"y": 80, | |
"wires": [ | |
[ | |
"afbee77071ea1c6f", | |
"fd7896fc51269661", | |
"6e9dd441c55e2f28" | |
] | |
] | |
}, | |
{ | |
"id": "c3b16b4864dc870b", | |
"type": "server-state-changed", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "haas button", | |
"server": "34a16949.b02c86", | |
"version": 4, | |
"exposeToHomeAssistant": false, | |
"haConfig": [ | |
{ | |
"property": "name", | |
"value": "" | |
}, | |
{ | |
"property": "icon", | |
"value": "" | |
} | |
], | |
"entityidfilter": "input_button.refresh_exchange_rate", | |
"entityidfiltertype": "exact", | |
"outputinitially": false, | |
"state_type": "str", | |
"haltifstate": "true", | |
"halt_if_type": "bool", | |
"halt_if_compare": "is", | |
"outputs": 2, | |
"output_only_on_state_change": true, | |
"for": "0", | |
"forType": "num", | |
"forUnits": "minutes", | |
"ignorePrevStateNull": false, | |
"ignorePrevStateUnknown": false, | |
"ignorePrevStateUnavailable": false, | |
"ignoreCurrentStateUnknown": false, | |
"ignoreCurrentStateUnavailable": false, | |
"outputProperties": [ | |
{ | |
"property": "payload", | |
"propertyType": "msg", | |
"value": "", | |
"valueType": "entityState" | |
} | |
], | |
"x": 150, | |
"y": 60, | |
"wires": [ | |
[], | |
[ | |
"f19ef6b3350e4947" | |
] | |
] | |
}, | |
{ | |
"id": "bf982c1f98aac536", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "Buy THB req", | |
"func": "msg.payload = {\n \"fiat\": \"THB\",\n \"page\": 1,\n \"rows\": 10,\n \"tradeType\": \"SELL\",\n \"asset\": \"USDT\",\n \"countries\": [],\n \"proMerchantAds\": false,\n \"shieldMerchantAds\": false,\n \"publisherType\": null,\n \"payTypes\": [\"BANK\"],\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 150, | |
"y": 220, | |
"wires": [ | |
[ | |
"86994024b15603d0" | |
] | |
] | |
}, | |
{ | |
"id": "86994024b15603d0", | |
"type": "http request", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "fetch adv", | |
"method": "POST", | |
"ret": "obj", | |
"paytoqs": "ignore", | |
"url": "https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"insecureHTTPParser": false, | |
"authType": "", | |
"senderr": false, | |
"headers": [ | |
{ | |
"keyType": "other", | |
"keyValue": "Content-Type", | |
"valueType": "other", | |
"valueValue": "application/json" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "User-Agent", | |
"valueType": "other", | |
"valueValue": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.171 Safari/537.36" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "Origin", | |
"valueType": "other", | |
"valueValue": "https://p2p.binance.com" | |
}, | |
{ | |
"keyType": "other", | |
"keyValue": "Referer", | |
"valueType": "other", | |
"valueValue": "https://p2p.binance.com/en/trade/TinkoffNew/USDT?fiat=RUB" | |
} | |
], | |
"x": 300, | |
"y": 220, | |
"wires": [ | |
[ | |
"c9ca9ca71fed4064" | |
] | |
] | |
}, | |
{ | |
"id": "afbee77071ea1c6f", | |
"type": "subflow:c54c0f35b8c1f9e4", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "", | |
"x": 290, | |
"y": 160, | |
"wires": [ | |
[ | |
"bf982c1f98aac536", | |
"beac65be37a076c9" | |
] | |
] | |
}, | |
{ | |
"id": "f19ef6b3350e4947", | |
"type": "subflow:c54c0f35b8c1f9e4", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "", | |
"x": 290, | |
"y": 80, | |
"wires": [ | |
[ | |
"2c4122873c5eb69f" | |
] | |
] | |
}, | |
{ | |
"id": "c9ca9ca71fed4064", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "parse", | |
"func": "const median = arr => {\n const mid = Math.floor(arr.length / 2),\n nums = [...arr].sort((a, b) => a - b);\n return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;\n};\n\nlet price = 0.0;\nlet trend = \"stag\";\nif (!!msg.payload.data) {\n let prices = [];\n msg.payload.data.forEach(el => {\n const advPrice = parseFloat(el?.adv?.price || \"0.0\");\n if (advPrice > 0.0) {\n prices.push(parseFloat(el?.adv?.price || \"0.0\"));\n }\n });\n\n if (prices.length > 0) {\n price = median(prices);\n\n const adv = msg.payload.data[0].adv;\n const cacheKey = `prices-of-${adv.asset}_${adv.fiatUnit}_${adv.tradeType}`;\n let lastPrices = flow.get(cacheKey) || [];\n const lastMedian = median(lastPrices);\n trend = price > lastMedian ? \"up\" : \"down\";\n\n lastPrices.push(price);\n if (lastPrices.length > 144) {\n lastPrices.shift();\n }\n\n flow.set(cacheKey, lastPrices);\n }\n}\n\nmsg.payload = {\n price,\n trend,\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 430, | |
"y": 220, | |
"wires": [ | |
[ | |
"246d88b9c97d865e" | |
] | |
] | |
}, | |
{ | |
"id": "d8257bb07eb13894", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "parse", | |
"func": "const median = arr => {\n const mid = Math.floor(arr.length / 2),\n nums = [...arr].sort((a, b) => a - b);\n return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;\n};\n\nlet price = 0.0;\nlet trend = \"stag\";\nif (!!msg.payload.data) {\n let prices = [];\n msg.payload.data.forEach(el => {\n const advPrice = parseFloat(el?.adv?.price || \"0.0\");\n if (advPrice > 0.0) {\n prices.push(parseFloat(el?.adv?.price || \"0.0\"));\n }\n });\n\n if (prices.length > 0) {\n price = median(prices);\n\n const adv = msg.payload.data[0].adv;\n const cacheKey = `prices-of-${adv.asset}_${adv.fiatUnit}_${adv.tradeType}`;\n let lastPrices = flow.get(cacheKey) || [];\n const lastMedian = median(lastPrices);\n trend = price > lastMedian ? \"up\" : \"down\";\n\n lastPrices.push(price);\n if (lastPrices.length > 144) {\n lastPrices.shift();\n }\n\n flow.set(cacheKey, lastPrices);\n }\n}\n\nmsg.payload = {\n price,\n trend,\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 430, | |
"y": 280, | |
"wires": [ | |
[ | |
"343e5f4ad7e85f53" | |
] | |
] | |
}, | |
{ | |
"id": "f32e1c1252d374a4", | |
"type": "function", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "format msg", | |
"func": "const thbGreen = 54778;\nconst thbRed = 54777;\nconst rubRed = 54780;\nconst rubGreen = 54781;\n\nmsg.payload = {\n text: `${msg.payload.price.toFixed(2)}`,\n icon: msg.payload.trend == \"up\" ? rubRed : rubGreen,\n};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 730, | |
"y": 220, | |
"wires": [ | |
[ | |
"fd7896fc51269661" | |
] | |
] | |
}, | |
{ | |
"id": "bde307c6a89334f6", | |
"type": "mqtt out", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "set up indicator", | |
"topic": "awtrix/indicator1", | |
"qos": "", | |
"retain": "", | |
"respTopic": "", | |
"contentType": "", | |
"userProps": "", | |
"correl": "", | |
"expiry": "", | |
"broker": "346df2a95aac5785", | |
"x": 960, | |
"y": 260, | |
"wires": [] | |
}, | |
{ | |
"id": "e7fb79c126121a2e", | |
"type": "mqtt out", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "set down indicator", | |
"topic": "awtrix/indicator3", | |
"qos": "", | |
"retain": "", | |
"respTopic": "", | |
"contentType": "", | |
"userProps": "", | |
"correl": "", | |
"expiry": "", | |
"broker": "346df2a95aac5785", | |
"x": 970, | |
"y": 320, | |
"wires": [] | |
}, | |
{ | |
"id": "fd7896fc51269661", | |
"type": "mqtt out", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "app: rub -> usdt", | |
"topic": "awtrix/custom/rub_usdt", | |
"qos": "", | |
"retain": "", | |
"respTopic": "", | |
"contentType": "", | |
"userProps": "", | |
"correl": "", | |
"expiry": "", | |
"broker": "346df2a95aac5785", | |
"x": 960, | |
"y": 160, | |
"wires": [] | |
}, | |
{ | |
"id": "6e9dd441c55e2f28", | |
"type": "mqtt out", | |
"z": "e3a7ecec68d5bbe7", | |
"name": "app: rub -> usdt", | |
"topic": "awtrix/custom/usdt_thb", | |
"qos": "", | |
"retain": "", | |
"respTopic": "", | |
"contentType": "", | |
"userProps": "", | |
"correl": "", | |
"expiry": "", | |
"broker": "346df2a95aac5785", | |
"x": 960, | |
"y": 80, | |
"wires": [] | |
}, | |
{ | |
"id": "34a16949.b02c86", | |
"type": "server", | |
"name": "Home Assistant", | |
"addon": true | |
}, | |
{ | |
"id": "346df2a95aac5785", | |
"type": "mqtt-broker", | |
"name": "haas", | |
"broker": "10.11.0.1", | |
"port": "1883", | |
"clientid": "", | |
"autoConnect": true, | |
"usetls": false, | |
"protocolVersion": "4", | |
"keepalive": "60", | |
"cleansession": true, | |
"birthTopic": "", | |
"birthQos": "0", | |
"birthPayload": "", | |
"birthMsg": {}, | |
"closeTopic": "", | |
"closeQos": "0", | |
"closePayload": "", | |
"closeMsg": {}, | |
"willTopic": "", | |
"willQos": "0", | |
"willPayload": "", | |
"willMsg": {}, | |
"userProps": "", | |
"sessionExpiry": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment