!S,20,5,1,24,24
!S,1,5,1,1,24,24,5,8
They are two variations on the same info, with the second giving bass and treble info. As separated by the commas:
!S is the beginning of the response, and triggers the parser
1 or 20 is the type of response - not important
5 represents the zone
1 represents the source: in the first string there is one "1" and is the audio source, in the second string there is another "1" representing a video source, which is extraneous.
24 and 24 are volume right and left in both strings
5 is bass
8 is treble
I came up with the following but i don't think I'm handling the commas right. Also, when the volume is a single digit the script wouldn't work anyway. Somehow I think I need to use text delimiters and/or set the response to a list then get the items from the list?
Any thoughts would be appreciated.
- Code: Select all
using terms from application "IndigoServer"
if value of variable "vauxResponse" contains "!s" then
set vauxResponseString to value of variable "vauxResponse" as string
log vauxResponseString
set vauxZoneNumber to (number 7 of vauxResponseString as number)
log vauxZoneNumber --as string
set vauxSourceNumber to (number 9 of vauxResponseString as number)
log vauxSourceNumber
set vauxVolumeLevel to (numbers 11 through 12 of vauxResponseString as number)
log vauxVolumeLevel
end if
try
if vauxZoneNumber is ("1" or "2" or "3") then set vauxZoneName to "Kitchen"
if vauxZoneNumber is 4 then set value of variable "vauxZoneName" to "LivRmDnRm" as string
if vauxZoneNumber is 5 then set value of "vauxZoneName" to "Game Room" as string
if vauxZoneNumber is 6 then set value of "vauxZoneName" to "Patio" as string
if vauxZoneNumber is 7 then set value of "vauxZoneName" to "Pool" as string
if vauxZoneNumber is 8 then set value of "vauxZoneName" to "MBR" as string
end try
try
if vauxSourceNumber is 0 then set value of "vauxSourceName" to "Off" as string
if vauxSourceNumber is 1 then set value of "vauxSourceName" to "Tuner" as string
if vauxSourceNumber is 2 then set value of "vauxSourceName" to "iTunesPan" as string
if vauxSourceNumber is 3 then set value of "vauxSourceName" to "iPodPool" as string
if vauxSourceNumber is 4 then set value of "vauxSourceName" to "PoolTuner" as string
if vauxSourceNumber is 5 then set value of "vauxSourceName" to "Cable" as string
end try
log ((value of variable "vauxZoneName" as string) & (value of variable "vauxSourceName" as string))
end using terms from