I figured I’d start this topic, just in case anyone else is using the Monoprice 6-zone home audio amp. I’ve been working on incorporating it into my OH setup to be able to control the zones via OH, but it’s still a work in progress. I am able to control the amp well (volume, source, etc), but still have to work on the rules that show status from the amp (I think I’m running into issues with timing the response parsing, and actually regex’ing the input). I’m kind of hoping that the community helps me develop this into a more suitable set of items/sitemap/rules for anyone out there that has this amp and would like to incorporate it into their OH system.
BTW, I’m using an RPI2 with a USB-RS232 adapter…
EDIT 28 Sept 2015: I found the time to fix my issues, and now have a reliably working set of rules/items/sitemaps configs to actually make this usable. Power/Source/Volume/Mute works, and status parsing appears reliable. All statuses are parsed out, but not everything is used. This can easily be extended to control Bass/Treble/Balance and the other options that are available. Let me know if you use it or have issues with it!
EDIT 1 March 2018: Incorporating @swamiller 's excellent work on simplifying and extending this code to work for multiple zones and all control functions, using much simpler design patterns (thanks to @rlkoshak 's suggestions, as well!). If you’re using a direct serial interface, use the items/rules/sitemap entries posted below. If you’re using a GlobalCache iTach Flex, use the code in post 5 from @swamiller.
EDIT 23 May 2020: @mlobstein wrote and published a brand new, COMPLETE binding for the Monoprice 10761 amp (and the other amps that follow the same serial API), see his post below to download the JAR. See my post below that for the updated .items and .sitemap config utilizing the new binding (all of the features are available, and the amp response is much faster than when using the old rules). I will leave the original items/sitemap/rules below for now, until the binding is formally merged with an upcoming release of OH (also for nostalgia, these rules served me well for the past 5+ years ). Enjoy!
ITEMS:
Group gZonePowerSwitch (all)
Group gZoneVolume (all)
Group gZoneMuteSwitch (all)
Group gZoneTone (all)
Group gZoneBalance (all)
Group gZoneSource (all)
Group gMonoPriceStatus (all)
String AudioMTX "Audio Matrix" { serial="/dev/ttyUSB0@9600" }
//String AudioMTX_Receive "Audio Matrix Receive"
Switch MonoPrice_Refresh "Refresh String"
//String MonoPrice_Receive_String "Received Response"
String MonoPrice_Status "MonoPrice Status [%s]"
String MonoPrice_Status_G1 "MP G1 (Zone) [%s]" (gMonoPriceStatus)
String MonoPrice_Status_G2 "MP G2 (PA Status) [%s]" (gMonoPriceStatus)
String MonoPrice_Status_G3 "MP G3 (Pwr Status) [%s]" (gMonoPriceStatus)
String MonoPrice_Status_G4 "MP G4 (Mute Status) [%s]" (gMonoPriceStatus)
String MonoPrice_Status_G5 "MP G5 (DT Status) [%s]" (gMonoPriceStatus)
Number MonoPrice_Status_G6 "MP G6 (Volume Status) [%.0f]" (gMonoPriceStatus)
Number MonoPrice_Status_G7 "MP G7 (Treble Status) [%.0f]" (gMonoPriceStatus)
Number MonoPrice_Status_G8 "MP G8 (Bass Status) [%.0f]" (gMonoPriceStatus)
Number MonoPrice_Status_G9 "MP G9 (Balance) [%.0f]" (gMonoPriceStatus)
Number MonoPrice_Status_G10 "MP G10 (Src Status) [%.0f]" (gMonoPriceStatus)
String MonoPrice_Status_G11 "MP G11 (Keypad Status) [%s]" (gMonoPriceStatus)
String MonoPrice_Z11 "Zone 1 Status [%s]"
String MonoPrice_Z12 "Zone 2 Status [%s]"
String MonoPrice_Z13 "Zone 3 Status [%s]"
String MonoPrice_Z14 "Zone 4 Status [%s]"
String MonoPrice_Z15 "Zone 5 Status [%s]"
String MonoPrice_Z16 "Zone 6 Status [%s]"
Switch MonoPrice_Z11_Power "Zone 1 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z12_Power "Zone 2 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z13_Power "Zone 3 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z14_Power "Zone 4 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z15_Power "Zone 5 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z16_Power "Zone 6 Power [%s]" <switch> (gZonePowerSwitch) [ "Switchable" ]
Switch MonoPrice_Z11_Mute "Zone 1 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Switch MonoPrice_Z12_Mute "Zone 2 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Switch MonoPrice_Z13_Mute "Zone 3 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Switch MonoPrice_Z14_Mute "Zone 4 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Switch MonoPrice_Z15_Mute "Zone 5 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Switch MonoPrice_Z16_Mute "Zone 6 Mute [%s]" <mute> (gZoneMuteSwitch) [ "Switchable" ]
Dimmer MonoPrice_Z11_Volume "Zone 1 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z12_Volume "Zone 2 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z13_Volume "Zone 3 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z14_Volume "Zone 4 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z15_Volume "Zone 5 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z16_Volume "Zone 6 Volume [%02d %%]" <soundvolume> (gZoneVolume) [ "Switchable" ]
Dimmer MonoPrice_Z11_Treble "Zone 1 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z12_Treble "Zone 2 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z13_Treble "Zone 3 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z14_Treble "Zone 4 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z15_Treble "Zone 5 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z16_Treble "Zone 6 Treble [%02d %%]" <treble> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z11_Bass "Zone 1 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z12_Bass "Zone 2 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z13_Bass "Zone 3 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z14_Bass "Zone 4 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z15_Bass "Zone 5 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z16_Bass "Zone 6 Bass [%02d %%]" <bass> (gZoneTone) [ "Switchable" ]
Dimmer MonoPrice_Z11_Balance "Zone 1 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Dimmer MonoPrice_Z12_Balance "Zone 2 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Dimmer MonoPrice_Z13_Balance "Zone 3 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Dimmer MonoPrice_Z14_Balance "Zone 4 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Dimmer MonoPrice_Z15_Balance "Zone 5 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Dimmer MonoPrice_Z16_Balance "Zone 6 Balance [%02d %%]" <control> (gZoneBalance) [ "Switchable" ]
Number MonoPrice_Z11_Source "Zone 1 Source [%.0f]" <control> (gZoneSource)
Number MonoPrice_Z12_Source "Zone 2 Source [%.0f]" <control> (gZoneSource)
Number MonoPrice_Z13_Source "Zone 3 Source [%.0f]" <control> (gZoneSource)
Number MonoPrice_Z14_Source "Zone 4 Source [%.0f]" <control> (gZoneSource)
Number MonoPrice_Z15_Source "Zone 5 Source [%.0f]" <control> (gZoneSource)
Number MonoPrice_Z16_Source "Zone 6 Source [%.0f]" <control> (gZoneSource)
SITEMAP:
Frame label="MonoPrice" {
Switch item=MonoPrice_Refresh
//Text item=AudioMTX_Receive
//Text item=MonoPrice_Status
//Text item=MonoPrice_Status_G1
// Text item=MonoPrice_Status_G2
// Text item=MonoPrice_Status_G3
// Text item=MonoPrice_Status_G4
// Text item=MonoPrice_Status_G5
// Text item=MonoPrice_Status_G6
// Text item=MonoPrice_Status_G7
// Text item=MonoPrice_Status_G8
// Text item=MonoPrice_Status_G9
// Text item=MonoPrice_Status_G10
// Text item=MonoPrice_Status_G11
Text item=MonoPrice_Z11
Switch item=MonoPrice_Z11_Power
Selection item=MonoPrice_Z11_Source label="Zone 1 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z11_Power==ON]
Slider item=MonoPrice_Z11_Volume visibility=[MonoPrice_Z11_Power==ON]
Switch item=MonoPrice_Z11_Mute visibility=[MonoPrice_Z11_Power==ON]
Slider item=MonoPrice_Z11_Treble visibility=[MonoPrice_Z11_Power==ON]
Slider item=MonoPrice_Z11_Bass visibility=[MonoPrice_Z11_Power==ON]
Slider item=MonoPrice_Z11_Balance visibility=[MonoPrice_Z11_Power==ON]
Text item=MonoPrice_Z12
Switch item=MonoPrice_Z12_Power
Selection item=MonoPrice_Z12_Source label="Zone 2 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z12_Power==ON]
Slider item=MonoPrice_Z12_Volume visibility=[MonoPrice_Z12_Power==ON]
Switch item=MonoPrice_Z12_Mute visibility=[MonoPrice_Z12_Power==ON]
Slider item=MonoPrice_Z12_Treble visibility=[MonoPrice_Z12_Power==ON]
Slider item=MonoPrice_Z12_Bass visibility=[MonoPrice_Z12_Power==ON]
Slider item=MonoPrice_Z12_Balance visibility=[MonoPrice_Z12_Power==ON]
Text item=MonoPrice_Z13
Switch item=MonoPrice_Z13_Power
Selection item=MonoPrice_Z13_Source label="Zone 3 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z13_Power==ON]
Slider item=MonoPrice_Z13_Volume visibility=[MonoPrice_Z13_Power==ON]
Switch item=MonoPrice_Z13_Mute visibility=[MonoPrice_Z13_Power==ON]
Slider item=MonoPrice_Z13_Treble visibility=[MonoPrice_Z13_Power==ON]
Slider item=MonoPrice_Z13_Bass visibility=[MonoPrice_Z13_Power==ON]
Slider item=MonoPrice_Z13_Balance visibility=[MonoPrice_Z13_Power==ON]
Text item=MonoPrice_Z14
Switch item=MonoPrice_Z14_Power
Selection item=MonoPrice_Z14_Source label="Zone 4 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z14_Power==ON]
Slider item=MonoPrice_Z14_Volume visibility=[MonoPrice_Z14_Power==ON]
Switch item=MonoPrice_Z14_Mute visibility=[MonoPrice_Z14_Power==ON]
Slider item=MonoPrice_Z14_Treble visibility=[MonoPrice_Z14_Power==ON]
Slider item=MonoPrice_Z14_Bass visibility=[MonoPrice_Z14_Power==ON]
Slider item=MonoPrice_Z14_Balance visibility=[MonoPrice_Z14_Power==ON]
Text item=MonoPrice_Z15
Switch item=MonoPrice_Z15_Power
Selection item=MonoPrice_Z15_Source label="Zone 5 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z15_Power==ON]
Slider item=MonoPrice_Z15_Volume visibility=[MonoPrice_Z15_Power==ON]
Switch item=MonoPrice_Z15_Mute visibility=[MonoPrice_Z15_Power==ON]
Slider item=MonoPrice_Z15_Treble visibility=[MonoPrice_Z15_Power==ON]
Slider item=MonoPrice_Z15_Bass visibility=[MonoPrice_Z15_Power==ON]
Slider item=MonoPrice_Z15_Balance visibility=[MonoPrice_Z15_Power==ON]
Text item=MonoPrice_Z16
Switch item=MonoPrice_Z16_Power
Selection item=MonoPrice_Z16_Source label="Zone 6 Source" mappings=[1=CH1,2=CH2,3=CH3,4=CH4,5=CH5,6=CH6] visibility=[MonoPrice_Z16_Power==ON]
Slider item=MonoPrice_Z16_Volume visibility=[MonoPrice_Z16_Power==ON]
Switch item=MonoPrice_Z16_Mute visibility=[MonoPrice_Z16_Power==ON]
Slider item=MonoPrice_Z16_Treble visibility=[MonoPrice_Z16_Power==ON]
Slider item=MonoPrice_Z16_Bass visibility=[MonoPrice_Z16_Power==ON]
Slider item=MonoPrice_Z16_Balance visibility=[MonoPrice_Z16_Power==ON]
}
RULES:
import java.util.regex.Matcher
import java.util.regex.Pattern
var String zone
rule "MonoPrice Status on command change"
when
Item MonoPrice_Status changed or
System started
then
var String MonoPrice_ResponseExpr = ">(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)"
var Pattern pattern = null
var Matcher matcher = null
pattern = Pattern::compile(MonoPrice_ResponseExpr)
matcher = pattern.matcher(AudioMTX.toString)
matcher.find()
Thread::sleep(300)
for(var int i = 1; i <= gMonoPriceStatus.members.size; i=i+1){
postUpdate("MonoPrice_Status_G"+i, matcher.group(i))
}
end
rule "Power (G3) Update"
when
Item MonoPrice_Status_G3 received update
then
if(MonoPrice_Status_G3.state == "01"){
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Power", "ON")
}
else {
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Power", "OFF")
}
end
rule "Mute (G4) Update"
when
Item MonoPrice_Status_G4 received update
then
if(MonoPrice_Status_G4.state == "01"){
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Mute", "ON")
}
else {
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Mute", "OFF")
}
end
rule "Volume (G6) Update"
when
Item MonoPrice_Status_G6 received update
then
val Number vol = ((MonoPrice_Status_G6.state as DecimalType) / 38 * 100).intValue
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Volume", vol.toString)
logInfo("MonoPrice", "G6 Volume updated to zone " + num + " Volume level " + vol)
end
rule "Treble (G7) Update"
when
Item MonoPrice_Status_G7 received update
then
val Number tre = ((MonoPrice_Status_G7.state as DecimalType) / 14 * 100).intValue
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Treble", tre.toString)
logInfo("MonoPrice", "G7 Treble updated to zone " + num + " Treble level " + tre)
end
rule "Bass (G8) Update"
when
Item MonoPrice_Status_G8 received update
then
val Number bas = ((MonoPrice_Status_G8.state as DecimalType) / 14 * 100).intValue
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Bass", bas.toString)
logInfo("MonoPrice", "G8 Bass updated to zone " + num + " Bass level " + bas)
end
rule "Balance (G9) Update"
when
Item MonoPrice_Status_G9 received update
then
val Number bal = ((MonoPrice_Status_G9.state as DecimalType) / 20 * 100).intValue
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Balance", bal.toString)
logInfo("MonoPrice", "G9 Balance updated to zone " + num + " Balance " + bal)
end
rule "Source (G10) Update"
when
Item MonoPrice_Status_G10 received update
then
val sor = MonoPrice_Status_G10.state
val int num = Integer::parseInt(MonoPrice_Status_G1.state.toString)
postUpdate("MonoPrice_Z"+num+"_Source", sor.toString)
logInfo("MonoPrice", "G10 Source updated to zone "+ num + " Source Number " + sor)
end
rule "Refresh Switch" //used during system startup, cycle through each zone
when
Item MonoPrice_Refresh received command ON or
System started
then
for(var int i=11; i <= 16; i = i+1){
AudioMTX.sendCommand("?"+i+"\r")
Thread::sleep(600)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
}
logInfo("Monoprice", "Monoprice Amp items refreshed")
end
rule "MonoPrice Zone Power"
when
Item MonoPrice_Z11_Power received command or
Item MonoPrice_Z12_Power received command or
Item MonoPrice_Z13_Power received command or
Item MonoPrice_Z14_Power received command or
Item MonoPrice_Z15_Power received command or
Item MonoPrice_Z16_Power received command
then
Thread::sleep(100)
val power = triggeringItem as SwitchItem
switch power {
case MonoPrice_Z11_Power: zone ="1"
case MonoPrice_Z12_Power: zone ="2"
case MonoPrice_Z13_Power: zone ="3"
case MonoPrice_Z14_Power: zone ="4"
case MonoPrice_Z15_Power: zone ="5"
case MonoPrice_Z16_Power: zone ="6"
}
if(receivedCommand==ON){
AudioMTX.sendCommand("<1" + zone + "PR01\r")
logInfo("MonoPrice", "Zone "+ zone + " Power ON")
}
else if(receivedCommand==OFF){
AudioMTX.sendCommand("<1" + zone + "PR00\r")
logInfo("MonoPrice", "Zone " + zone + " Power OFF")
}
AudioMTX.sendCommand("?1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end
rule "MonoPrice Zone Volume"
when
Item MonoPrice_Z11_Volume received command or
Item MonoPrice_Z12_Volume received command or
Item MonoPrice_Z13_Volume received command or
Item MonoPrice_Z14_Volume received command or
Item MonoPrice_Z15_Volume received command or
Item MonoPrice_Z16_Volume received command
then
Thread::sleep(100)
val volume = triggeringItem as DimmerItem
var Number volume_z
switch volume {
case MonoPrice_Z11_Volume: zone ="1"
case MonoPrice_Z12_Volume: zone ="2"
case MonoPrice_Z13_Volume: zone ="3"
case MonoPrice_Z14_Volume: zone ="4"
case MonoPrice_Z15_Volume: zone ="5"
case MonoPrice_Z16_Volume: zone ="6"
}
if(receivedCommand instanceof PercentType) {
volume_z = receivedCommand
volume_z = (volume_z * 38 / 100).intValue
} else {
if(receivedCommand==INCREASE)
{
volume_z = volume_z + 1
}
if(receivedCommand==DECREASE)
{
volume_z = volume_z - 1
}
}
if (volume_z>9) {AudioMTX.sendCommand("<1" + zone + "VO" + volume_z.toString + "\r") }
else {AudioMTX.sendCommand("<1" + zone + "VO0" + volume_z.toString + "\r") }
volume.postUpdate((volume_z / 38 * 100).intValue)
AudioMTX.sendCommand("?1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end
rule "MonoPrice Zone Mute"
when
Item MonoPrice_Z11_Mute received command or
Item MonoPrice_Z12_Mute received command or
Item MonoPrice_Z13_Mute received command or
Item MonoPrice_Z14_Mute received command or
Item MonoPrice_Z15_Mute received command or
Item MonoPrice_Z16_Mute received command
then
Thread::sleep(100)
val mute = triggeringItem as SwitchItem
switch mute {
case MonoPrice_Z11_Mute: zone ="1"
case MonoPrice_Z12_Mute: zone ="2"
case MonoPrice_Z13_Mute: zone ="3"
case MonoPrice_Z14_Mute: zone ="4"
case MonoPrice_Z15_Mute: zone ="5"
case MonoPrice_Z16_Mute: zone ="6"
}
if(receivedCommand==ON){
AudioMTX.sendCommand("<1" + zone + "MU01\r")
logInfo("MonoPrice", "Zone "+ zone + " Mute ON")
}
else if(receivedCommand==OFF){
AudioMTX.sendCommand("<1" + zone + "MU00\r")
logInfo("MonoPrice", "Zone " + zone + " Mute OFF")
}
AudioMTX.sendCommand("?1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end
rule "MonoPrice Zone Source"
when
Item MonoPrice_Z11_Source received command or
Item MonoPrice_Z12_Source received command or
Item MonoPrice_Z13_Source received command or
Item MonoPrice_Z14_Source received command or
Item MonoPrice_Z15_Source received command or
Item MonoPrice_Z16_Source received command
then
Thread::sleep(100)
val source = triggeringItem as NumberItem
switch source {
case MonoPrice_Z11_Source: zone ="1"
case MonoPrice_Z12_Source: zone ="2"
case MonoPrice_Z13_Source: zone ="3"
case MonoPrice_Z14_Source: zone ="4"
case MonoPrice_Z15_Source: zone ="5"
case MonoPrice_Z16_Source: zone ="6"
}
AudioMTX.sendCommand("<1" + zone + "CH0" + source.state.toString + "\r")
AudioMTX.sendCommand("?1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end
rule "MonoPrice Zone Tone"
when
Item MonoPrice_Z11_Treble received command or
Item MonoPrice_Z12_Treble received command or
Item MonoPrice_Z13_Treble received command or
Item MonoPrice_Z14_Treble received command or
Item MonoPrice_Z15_Treble received command or
Item MonoPrice_Z16_Treble received command or
Item MonoPrice_Z11_Bass received command or
Item MonoPrice_Z12_Bass received command or
Item MonoPrice_Z13_Bass received command or
Item MonoPrice_Z14_Bass received command or
Item MonoPrice_Z15_Bass received command or
Item MonoPrice_Z16_Bass received command
then
var Number toneslider_z
var String tone_z
Thread::sleep(100)
val tone = triggeringItem as DimmerItem
switch tone {
case MonoPrice_Z11_Treble: {
zone ="1"
tone_z = "1TR"
}
case MonoPrice_Z12_Treble: {
zone ="2"
tone_z = "2TR"
}
case MonoPrice_Z13_Treble: {
zone ="3"
tone_z = "3TR"
}
case MonoPrice_Z14_Treble: {
zone ="4"
tone_z = "4TR"
}
case MonoPrice_Z15_Treble: {
zone ="5"
tone_z = "5TR"
}
case MonoPrice_Z16_Treble: {
zone ="6"
tone_z = "6TR"
}
case MonoPrice_Z11_Bass: {
zone ="1"
tone_z = "1BS"
}
case MonoPrice_Z12_Bass: {
zone ="2"
tone_z = "2BS"
}
case MonoPrice_Z13_Bass: {
zone ="3"
tone_z = "3BS"
}
case MonoPrice_Z14_Bass: {
zone ="4"
tone_z = "4BS"
}
case MonoPrice_Z15_Bass:{
zone ="5"
tone_z = "5BS"
}
case MonoPrice_Z16_Bass: {
zone ="6"
tone_z = "6BS"
}
}
if(receivedCommand instanceof PercentType) {
toneslider_z = receivedCommand
toneslider_z = (toneslider_z * 14 / 100).intValue
} else {
if(receivedCommand==INCREASE)
{
toneslider_z = toneslider_z + 1
}
if(receivedCommand==DECREASE)
{
toneslider_z = toneslider_z - 1
}
}
if (toneslider_z>9) {AudioMTX.sendCommand("<1" + tone_z + toneslider_z.toString + "\r") }
else {AudioMTX.sendCommand("<1" + tone_z + "0" + toneslider_z + "\r") }
tone.postUpdate((toneslider_z / 14 * 100).intValue)
AudioMTX.sendCommand("<1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end
rule "MonoPrice Zone Balance"
when
Item MonoPrice_Z11_Balance received command or
Item MonoPrice_Z12_Balance received command or
Item MonoPrice_Z13_Balance received command or
Item MonoPrice_Z14_Balance received command or
Item MonoPrice_Z15_Balance received command or
Item MonoPrice_Z16_Balance received command
then
var Number balance_z
val balance = triggeringItem as DimmerItem
Thread::sleep(100)
switch balance {
case MonoPrice_Z11_Balance: zone ="1"
case MonoPrice_Z12_Balance: zone ="2"
case MonoPrice_Z13_Balance: zone ="3"
case MonoPrice_Z14_Balance: zone ="4"
case MonoPrice_Z15_Balance: zone ="5"
case MonoPrice_Z16_Balance: zone ="6"
}
if(receivedCommand instanceof PercentType) {
balance_z = receivedCommand
balance_z = (balance_z * 20 / 100).intValue
} else {
if(receivedCommand==INCREASE)
{
balance_z = balance_z + 1
}
if(receivedCommand==DECREASE)
{
balance_z = balance_z - 1
}
}
if (balance_z>9) {AudioMTX.sendCommand("<1" + zone + "BL" + balance_z.toString + "\r") }
else {AudioMTX.sendCommand("<1" + zone + "BL0" + balance_z.toString + "\r") }
balance.postUpdate((balance_z / 20 * 100).intValue)
AudioMTX.sendCommand("?1" + zone + "\r")
Thread::sleep(300)
MonoPrice_Status.postUpdate(AudioMTX.state.toString.trim)
end