Skip to content

Instantly share code, notes, and snippets.

@byBobo
Created April 13, 2021 13:42
Show Gist options
  • Save byBobo/442c82114904b20f6802c2599c32edee to your computer and use it in GitHub Desktop.
Save byBobo/442c82114904b20f6802c2599c32edee to your computer and use it in GitHub Desktop.
[{"id":"bf60b8.b136b748","type":"http request","z":"5f0a7d11.3d2dd4","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://www.freeforexapi.com/api/live?pairs={{payload.from}}{{payload.to}}","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":760,"wires":[["759fac8f.720bd4","10c356bd.29f009"]]},{"id":"10c356bd.29f009","type":"function","z":"5f0a7d11.3d2dd4","name":"","func":"const value = flow.get(\"value\");\nconst from = flow.get(\"from\");\nconst to = flow.get(\"to\");\n\nconst rates = msg.payload.rates;\nconst pair = from + to;\n\n\nconst rate = rates[pair].rate;\nconst result = value * rate;\n\nmsg.payload.result = result;\nmsg.payload.value = value;\nmsg.payload.message = `${value} ${from} = ${result.toFixed(2)} ${to}`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":740,"wires":[["2d5a9fbd.c7d008"]]},{"id":"759fac8f.720bd4","type":"debug","z":"5f0a7d11.3d2dd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":780,"wires":[]},{"id":"e4cab682.a14598","type":"ui_text_input","z":"5f0a7d11.3d2dd4","name":"","label":"","tooltip":"","group":"b750e8e.87cde18","order":3,"width":"4","height":"1","passthru":true,"mode":"number","delay":300,"topic":"payload.value","topicType":"msg","x":250,"y":540,"wires":[["a1973af7.20f3f"]]},{"id":"2d5a9fbd.c7d008","type":"ui_text","z":"5f0a7d11.3d2dd4","group":"b750e8e.87cde18","order":4,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.message}}","layout":"row-spread","x":760,"y":740,"wires":[]},{"id":"c60c34d1.257e","type":"ui_dropdown","z":"5f0a7d11.3d2dd4","name":"","label":"from","tooltip":"","place":"Select option","group":"b750e8e.87cde18","order":1,"width":"4","height":"1","passthru":true,"multiple":false,"options":[{"label":"EUR","value":"EUR","type":"str"},{"label":"USD","value":"USD","type":"str"},{"label":"GBP","value":"GBP","type":"str"}],"payload":"","topic":"payload.from","topicType":"msg","x":230,"y":480,"wires":[["40f2b184.591cb"]]},{"id":"15137eaa.baaab9","type":"ui_dropdown","z":"5f0a7d11.3d2dd4","name":"","label":"to","tooltip":"","place":"Select option","group":"b750e8e.87cde18","order":1,"width":"4","height":"1","passthru":true,"multiple":false,"options":[{"label":"EUR","value":"EUR","type":"str"},{"label":"USD","value":"USD","type":"str"},{"label":"GBP","value":"GBP","type":"str"}],"payload":"","topic":"payload.to","topicType":"msg","x":210,"y":640,"wires":[["f0831588.228b58","81cca0e3.4dd0f8"]]},{"id":"628853bf.66bfd4","type":"ui_button","z":"5f0a7d11.3d2dd4","name":"","group":"b750e8e.87cde18","order":0,"width":"1","height":"1","passthru":false,"label":"covert","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"payload","topicType":"msg","x":70,"y":500,"wires":[["c60c34d1.257e","e4cab682.a14598","15137eaa.baaab9"]]},{"id":"f0831588.228b58","type":"debug","z":"5f0a7d11.3d2dd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":640,"wires":[]},{"id":"81cca0e3.4dd0f8","type":"change","z":"5f0a7d11.3d2dd4","name":"","rules":[{"t":"set","p":"to","pt":"flow","to":"payload.to","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":700,"wires":[[]]},{"id":"a1973af7.20f3f","type":"change","z":"5f0a7d11.3d2dd4","name":"","rules":[{"t":"set","p":"value","pt":"flow","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":540,"wires":[[]]},{"id":"40f2b184.591cb","type":"change","z":"5f0a7d11.3d2dd4","name":"","rules":[{"t":"set","p":"from","pt":"flow","to":"payload.from","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":480,"wires":[["b184ada5.dd328"]]},{"id":"b184ada5.dd328","type":"debug","z":"5f0a7d11.3d2dd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":440,"wires":[]},{"id":"4443ef91.b50528","type":"inject","z":"5f0a7d11.3d2dd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":740,"wires":[["7350d4db.4a5ddc"]]},{"id":"7350d4db.4a5ddc","type":"debug","z":"5f0a7d11.3d2dd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":210,"y":800,"wires":[]},{"id":"b750e8e.87cde18","type":"ui_group","name":"cambia-valuta","tab":"414a2b76.3ce37c","order":1,"disp":true,"width":"6","collapse":false},{"id":"414a2b76.3ce37c","type":"ui_tab","name":"cambia-valuta","icon":"dashboard","disabled":false,"hidden":false}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment