Hello !
I created a sitemap with a Volume control slider element in it in order to control my Surround Receiver Over an RS-232 binding.
Here is the my items :
String Amp_Command "Amplifier Info " { serial="COM4" }
Dimmer Amp_Volume "Amplifier Volume " <soundvolume>
\\ Here is my rule;
rule "Volume Change"
when
Item Amp_Volume received update
then
var Value = Amp_Volume.state as Number
var KitVol = ( Value / 2 ) - 50
var String MyOutput = KitVol.toString
logInfo ("MyLog", "MyOutput{}", MyOutput)
if ( KitVol < 0 )
{
sendCommand(Amp_Command, "@VOL:0" + KitVol.intValue + "\r")
}
else {
if ( KitVol == 0 )
{
sendCommand(Amp_Command, "@VOL:0-" + KitVol.intValue + "0\r")
}
else if ( KitVol > 0 && KitVol < 10 )
{
sendCommand(Amp_Command, "@VOL:0+0" + KitVol.intValue + "\r")
}
else {
sendCommand(Amp_Command, "@VOL:0+" + KitVol.intValue + "\r")
}
}
end
\\ and finally my Slider item in the sitemap
Slider item=Amp_Volume label="Ses Seviyesi [%.1f dB]"
Although the slider values change from 0 to 100, my amplifier requires level of Volume between -50 to 0 dB , so my rule is created in order to scale the slider value and convert it to a serial code
This is the visual of my slider item;
Here, what the slider displays is labels own Value which varies from 0 to 100.
I can control the Volume perfectly but,
My question is how can I make it show the actual dB value which ranges from -50 dB to 0 dB in the sitemap? Is there any method for assigning the value of label from other items?
Thanks,
Erdal