Pull song title and artist from Sonos audio data


#1

1) Give a description of the problem
I am able to view all the track information but I need to separate out the song title and artist into another variable. I have tried various mid/left/right indexof expressions but I cannot isolate the song title and song artist in variables.

2) What is the expected behaviour?
(PUT YOUR INFO HERE)

3) What is happening/not happening?
(PUT YOUR INFO HERE)

**4)

5) Attach logs after turning logging level to Full
3/1/2021, 11:14:24 AM +832ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+554ms ║╔Subscribing to devices…
+590ms ║║Subscribing to 34.switch…
+706ms ║║Subscribing to Soundbar…
+707ms ║╚Finished subscribing (168ms)
+745ms ╚Piston successfully started (745ms)
3/1/2021, 11:10:56 AM +979ms
+1ms ╔Received event [34].switch = off with a delay of 148ms
+63ms ║RunTime Analysis CS > 20ms > PS > 17ms > PE > 26ms > CE
+65ms ║Runtime (40215 bytes) successfully initialized in 17ms (v0.3.110.20191009) (63ms)
+66ms ║╔Execution stage started
+73ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+74ms ║║Cancelling condition #5’s schedules…
+75ms ║║Condition #5 evaluated false (5ms)
+76ms ║║Cancelling condition #1’s schedules…
+77ms ║║Condition group #1 evaluated false (state changed) (7ms)
+78ms ║╚Execution stage complete. (12ms)
+79ms ╚Event processed successfully (79ms)
3/1/2021, 11:10:48 AM +654ms
+1ms ╔Received event [34].switch = on with a delay of 84ms
+62ms ║RunTime Analysis CS > 21ms > PS > 9ms > PE > 32ms > CE
+65ms ║Runtime (40112 bytes) successfully initialized in 9ms (v0.3.110.20191009) (62ms)
+66ms ║╔Execution stage started
+73ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+75ms ║║Cancelling condition #5’s schedules…
+76ms ║║Condition #5 evaluated true (6ms)
+77ms ║║Cancelling condition #1’s schedules…
+78ms ║║Condition group #1 evaluated true (state changed) (8ms)
+80ms ║║Cancelling statement #6’s schedules…
+85ms ║║Executed virtual command [Soundbar].wait (1ms)
+86ms ║║Waiting for 4000ms
+4130ms ║║Executed virtual command [Soundbar].setVariable (3ms)
+4136ms ║║Executed virtual command [Soundbar].setVariable (3ms)
+4141ms ║║Executed virtual command [Soundbar].setVariable (2ms)
+4147ms ║║{“title”:“willow”,“artist”:“Taylor Swift”,“album”:“evermore [Explicit]”,“mediaSource”:“Amazon Music”}
+4148ms ║║Executed virtual command [Soundbar].log (2ms)
+4153ms ║║Executed virtual command [Soundbar].setVariable (3ms)
+4156ms ║╚Execution stage complete. (4090ms)
+4157ms ╚Event processed successfully (4157ms)


#2

audioTrackData is in JSON format, after saving it in a variable you can then parse and set additional varaibles using the expressions $json.title, $json.astist, etc.

See my example below:
image


#3

That’s just what I needed. Thank you so much for the clear and prompt response.