#!/bin/bash # Create a Domoticz Hardware of type Dummy # Create two Virtual Sensors of type Custom Sensor # 1 sensor with name BitcoinValue and 1 sensor with name BitcoinWallet # Enter amount of bitcoins in your wallet here: number='0.1' # SET the required currency: USD, GBP, EUR currency="USD" # enter BitcoinValue Domoticz DeviceIdx: bitcoinvalueidx=9461 # enter BitcoinWallet Domoticz DeviceIdx: bitcoinwalletidx=9457 # add to crontab, without the comment # # crontab -e # */15 * * * * sleep $(expr $RANDOM \% 600); /home/pi/domoticz/scripts/bitcoin/bitcoin.sh 2>&1 PLN=$(curl -s http://api.nbp.pl/api/exchangerates/rates/a/usd?format=json | sed 's/","/\n/g' | grep 'mid"' | cut -c 6-10) echo $PLN bitcoin=$(curl -s http://api.coindesk.com/v1/bpi/currentprice.json | sed 's/","/\n/g' | grep -A2 $currency | grep 'rate"' | cut -d'"' -f3 | tr -d ",") echo $bitcoin wallet=$(awk "BEGIN {print $number*$bitcoin}") echo $wallet BTCPLN=$(awk "BEGIN {print $PLN*$bitcoin}") echo $BTCPLN KursBTCPLN=$(awk "BEGIN {print $number*$BTCPLN}") echo $KursBTCPLN if [ "$bitcoin" != "" ] && [ "${bitcoin%.*}" -gt "100" ] ; then curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=$bitcoinvalueidx&nvalue=0&svalue=$bitcoin;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=$bitcoinwalletidx&nvalue=0&svalue=$wallet;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=9457&nvalue=0&svalue=$bitcoin;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=9461&nvalue=0&svalue=$wallet;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=9462&nvalue=0&svalue=$PLN;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=9463&nvalue=0&svalue=$KursBTCPLN;0" curl "http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=9464&nvalue=0&svalue=$BTCPLN;0" fi