Manipulating String Value

Wanted to know how I can take the value from my onkyo receiver and divide it by half.

for example, currently my onkyo receiver volume value is displayed as % (i.e. 75%). i would like to display this value as 37.5. so basically dividing it by two and no % sign.

so far i have tried {0:N1}, which takes out the percentage and displays it as an integer with 1 decimal. now how do i divide that by 2.

String formatting cannot perform calculations. You have a couple options here. You can use data triggers. Although you’ll probably need a bunch of them. That option may not be practical. Your other option is to create a virtual device & a scene. Create a Scene that is triggered by any value change on that variable. Then add an Action to that Scene that runs a script which reads the value from the Onkyo device & performs the calculation. Finally, forward that value to the virtual device variable.

1)i was able to setup a scene and trigger value correctly w/ Regex of 1-200.

2)For data Action i called the script.
var currentvolume = App.GetDeviceAttribute(“TxNr797Main.Volume”);
var newvolume = currentvolume / 2
App.SetDeviceAttribute(“VirtualDevice.Volume”, newvolume)

3)I have my + and - volume button setup so they execute the scene every time i press them. Not sure if that is the best way or not?

  1. How do i handle the Volume slide bar. So it can run scene1

OnkyoVolume.hrp (184.5 KB)

sorry i am a newbie. still learning