Wer Kurse auch im NodeRed-Dashboard anzeigen bzw. umrechnen will, kann diesen Beispiel Flow als Template verwenden.
Die Funktion ist schnell erklärt. Es wird nach der Eingabe des Bitcoin Wert (Achtung, kein Komma, nur den Dezimalpunkt verwenden) der Kurs bei Kraken abgefragt und der aktuelle BTC in Euro umgerechnet. Der Beispiel Button, im Flow, erzeugt z.B. den Wert für 1000 Euro. Kann ja leicht angepasst werden oder auch direkt vom Konto eingspielt werden, wie hier schon mal gezeigt. …
Hier der Beispiel-Flow:
Hier der Code:
1 |
[{"id":"6d623bc8.8945d4","type":"tab","label":"BTC to Euro","disabled":false,"info":""},{"id":"41f59dfb.56643c","type":"group","z":"6d623bc8.8945d4","name":"","style":{"fill":"#d1d1d1","label":true},"nodes":["584b7599.5a734c","86b45ce2.199c48","83cfa869.6e347","df2a6383.f71d08","5553d2d0.40ecd4","8bd23aaa.333798"],"x":94,"y":119,"w":992,"h":122},{"id":"584b7599.5a734c","type":"function","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"JSON to BTC in Euro","func":"msg.payload = msg.payload.result.XXBTZEUR.a[0] * msg.bitcoin|0\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":160,"wires":[["86b45ce2.199c48","df2a6383.f71d08"]]},{"id":"86b45ce2.199c48","type":"debug","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"Konsole","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":980,"y":200,"wires":[]},{"id":"83cfa869.6e347","type":"http request","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"Bitcoin Kurs abfragen","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.kraken.com/0/public/Ticker?pair=BTCEUR","tls":"","persist":false,"proxy":"","authType":"","x":580,"y":160,"wires":[["584b7599.5a734c"]]},{"id":"8ecf18b2.b372","type":"inject","z":"6d623bc8.8945d4","name":"Konstanter BTC Kurs abfrage z.B. 0.022","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0.022","payloadType":"str","x":260,"y":60,"wires":[["5553d2d0.40ecd4"]]},{"id":"df2a6383.f71d08","type":"ui_gauge","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"Anzeige","group":"df689168.e5f65","order":0,"width":0,"height":0,"gtype":"gage","title":"Bitcoin (BTC) Kurs in Euro","label":"Euro = {{msg.bitcoin}} BTC","format":"{{msg.payload}}","min":0,"max":"100000","colors":["#ff2600","#e6e600","#00f900"],"seg1":"100","seg2":"103","x":980,"y":160,"wires":[]},{"id":"5553d2d0.40ecd4","type":"ui_text_input","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"","label":"Eingabe BTC","tooltip":"","group":"df689168.e5f65","order":11,"width":"6","height":"1","passthru":true,"mode":"text","delay":300,"topic":"bitcoin","topicType":"msg","x":190,"y":160,"wires":[["8bd23aaa.333798"]]},{"id":"8bd23aaa.333798","type":"function","z":"6d623bc8.8945d4","g":"41f59dfb.56643c","name":"payload to bitcoin","func":"msg.bitcoin = msg.payload\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":160,"wires":[["83cfa869.6e347"]]},{"id":"b74152bb.45cdc8","type":"comment","z":"6d623bc8.8945d4","name":"Buy my a coffee: bitcoin:bc1qj4grttyhk2h5wqask3nku70e3qtycssz5kvw5l","info":"","x":360,"y":300,"wires":[]},{"id":"2263698f.cc311e","type":"comment","z":"6d623bc8.8945d4","name":"(c) 2021 Thomas Wenzlaff www.wenzlaff.info","info":"Quelle: \n\nhttps://bitcoinfees.earn.com/api\n\nhttps://bitcoinfees.earn.com\n\n\nhttps://mempool.space/api/v1/fees/recommended\n\nhttps://mempool.space/de/api","x":910,"y":300,"wires":[]},{"id":"df689168.e5f65","type":"ui_group","name":"BTC to Euro","tab":"2de6e104.34cd0e","order":1,"disp":true,"width":"6","collapse":false},{"id":"2de6e104.34cd0e","type":"ui_tab","name":"BTC to Euro","icon":"fa-btc","disabled":false,"hidden":false}] |