Announcement

Collapse
No announcement yet.

Request for new device - Value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request for new device - Value

    First, thanks for another great plug-in! A nice convenience to see my Bitcoin balance without logging in to a website.

    Would it be possible to get another device created to display the actual value of the Bitcoins? Or, could you show me how to put it into a script to display the Value in a device? That way we can see the actual dollar amount in whatever currency we are tracking, in my case US Dollars.

    Right now I have: Balance and BTC/USD
    I would like: Value (BTC/USD * Balance)

    Thanks
    Bryan
    Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
    Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave

  • #2
    create a "Balance USD" device like this one:
    Click image for larger version

Name:	balanceusd.jpg
Views:	1
Size:	52.9 KB
ID:	1174455

    then create an event like below that will update the "Balance USD" device value everytime the Bitcoin balance or exchange rate is updated:

    Click image for larger version

Name:	balanceusdevent.jpg
Views:	1
Size:	50.3 KB
ID:	1174456

    here is the content of bitcoin_balance_usd.cs

    Code:
    public object Main(object[] Parms)
    {
        int balanceUSDRef = hs.GetDeviceRefByName("Balance USD");
        int balanceRef = hs.GetDeviceRefByName("Balance");
        int BTCUSDRef = hs.GetDeviceRefByName("BTC/USD");
        double balance = hs.DeviceValueEx(balanceRef);
        double BTCUSD = hs.DeviceValueEx(BTCUSDRef);
        
        hs.SetDeviceValueByRef(balanceUSDRef, balance * BTCUSDRef, true);
        return 0;
    }

    Comment


    • #3
      Thank you very much!

      At first I couldn't get the answer to be correct...I kept looking at the script and finally found the typo.

      This line:
      hs.SetDeviceValueByRef(balanceUSDRef, balance * BTCUSDRef, true);

      Needs to be:
      hs.SetDeviceValueByRef(balanceUSDRef, balance * BTCUSD, true);

      Once that was fixed it works perfect!

      Thanks again!
      Bryan
      Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
      Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave

      Comment


      • #4
        ooops sorry for the typo
        I had checked that a value was set to the "balance USD", but not that this value was correct.

        Comment

        Working...
        X