1) Give a description of the problem
I’m able to make a web call which returns json data, however, I’m not sure on how to extract a specific piece of the json data and set it to a variable for future use.
What’s returning based on the logs is this:
+155ms ║║{“volume”:44,“mute”:false,“equalizer”:{“bass”:7,“treble”:2,“loudness”:true},“currentTrack”:{“artist”:“57 - No Shoes Radio”,“title”:“BR P|TYPE=SNG|TITLE Gravedigger|ARTIST Willie Nelson|ALBUM”,“albumArtUri”:“http://www.siriusxm.com/albumart/Live/1730/willienelson_4EFF3F28_m.jpg",“duration”:0,“uri”:“x-sonosapi-hls:r%3A9418?sid=37&flags=8480&sn=1”,“type”:“radio”,“stationName”:"57 - No Shoes Radio”,“absoluteAlbumArtUri”:“http://www.siriusxm.com/albumart/Live/1730/willienelson_4EFF3F28_m.jpg"},“nextTrack”:{“artist”:"",“title”:"",“album”:"",“albumArtUri”:"",“duration”:0,“uri”:""},“trackNo”:1,“elapsedTime”:122,“elapsedTimeFormatted”:“00:02:02”,“playbackState”:“PLAYING”,“playMode”:{“repeat”:“none”,“shuffle”:false,"crossfade”:false}}
I’m trying to pull out the “URI” field in order to pass it back to a sonos speaker later on in another part of the piston… (in effect, store current station that’s playing, execute piston which changes the song, then tell sonos to resume whatever the “uri” was prior)…
Here’s some logs, any help on parsing json would be appreciated… I’ve searched the forum, but only came across about 5 threads, which did help to get me started down this path…now my head hurts slight_smile:
12/22/2017, 12:54:41 PM +606ms
+93ms ╔Stopping piston…
+221ms ╚Piston successfully stopped (127ms)
12/22/2017, 12:54:29 PM +320ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+286ms ║RunTime Analysis CS > 19ms > PS > 219ms > PE > 47ms > CE
+288ms ║Runtime (44577 bytes) successfully initialized in 219ms (v0.2.100.20171211) (286ms)
+289ms ║╔Execution stage started
+311ms ║╚Execution stage complete. (22ms)
+312ms ╚Event processed successfully (312ms)
12/22/2017, 12:54:28 PM +640ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+89ms ║RunTime Analysis CS > 18ms > PS > 27ms > PE > 44ms > CE
+92ms ║Runtime (44574 bytes) successfully initialized in 27ms (v0.2.100.20171211) (90ms)
+93ms ║╔Execution stage started
+124ms ║║Sending internal web request to: 192.168.1.231:5005/Kitchen%20Play1/playlist/SexyTime
+126ms ║║Executed virtual command [Kitchen - Red].httpRequest (3ms)
+127ms ║║Requesting a wake up for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 20.0s)
+133ms ║╚Execution stage complete. (40ms)
+135ms ║Setting up scheduled job for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 19.994s)
+147ms ╚Event processed successfully (147ms)
12/22/2017, 12:54:28 PM +258ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+124ms ║RunTime Analysis CS > 16ms > PS > 65ms > PE > 43ms > CE
+128ms ║Runtime (44575 bytes) successfully initialized in 65ms (v0.2.100.20171211) (126ms)
+128ms ║╔Execution stage started
+150ms ║║Executed virtual command [Kitchen - Red].parseJson (1ms)
+155ms ║║{“volume”:44,“mute”:false,“equalizer”:{“bass”:7,“treble”:2,“loudness”:true},“currentTrack”:{“artist”:“57 - No Shoes Radio”,“title”:“BR P|TYPE=SNG|TITLE Gravedigger|ARTIST Willie Nelson|ALBUM”,“albumArtUri”:“http://www.siriusxm.com/albumart/Live/1730/willienelson_4EFF3F28_m.jpg",“duration”:0,“uri”:“x-sonosapi-hls:r%3A9418?sid=37&flags=8480&sn=1”,“type”:“radio”,“stationName”:"57 - No Shoes Radio”,“absoluteAlbumArtUri”:“http://www.siriusxm.com/albumart/Live/1730/willienelson_4EFF3F28_m.jpg"},“nextTrack”:{“artist”:"",“title”:"",“album”:"",“albumArtUri”:"",“duration”:0,“uri”:""},“trackNo”:1,“elapsedTime”:122,“elapsedTimeFormatted”:“00:02:02”,“playbackState”:“PLAYING”,“playMode”:{“repeat”:“none”,“shuffle”:false,"crossfade”:false}}
+156ms ║║Executed virtual command [Kitchen - Red].log (1ms)
+162ms ║║Sending internal web request to: 192.168.1.231:5005/Kitchen%20Play1/pauseall
+164ms ║║Executed virtual command [Kitchen - Red].httpRequest (3ms)
+165ms ║║Requesting a wake up for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 20.0s)
+169ms ║╚Execution stage complete. (41ms)
+170ms ║Setting up scheduled job for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 19.995s)
+184ms ╚Event processed successfully (184ms)
12/22/2017, 12:54:27 PM +795ms
+1ms ╔Received event [Aeon Minimote].button = pushed with a delay of 283ms
+122ms ║RunTime Analysis CS > 12ms > PS > 66ms > PE > 44ms > CE
+124ms ║Runtime (44575 bytes) successfully initialized in 66ms (v0.2.100.20171211) (123ms)
+125ms ║╔Execution stage started
+134ms ║║Comparison (enum) pushed gets (string) pushed = false (1ms)
+135ms ║║Condition #4 evaluated false (5ms)
+136ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+141ms ║║Comparison (enum) pushed gets (string) held = false (0ms)
+142ms ║║Condition #10 evaluated false (4ms)
+143ms ║║Condition group #7 evaluated false (state did not change) (4ms)
+149ms ║║Comparison (enum) pushed gets (string) pushed = true (2ms)
+150ms ║║Cancelling condition #21’s schedules…
+151ms ║║Condition #21 evaluated true (6ms)
+152ms ║║Cancelling condition #15’s schedules…
+153ms ║║Condition group #15 evaluated true (state changed) (7ms)
+155ms ║║Cancelling statement #17’s schedules…
+197ms ║║Executed physical command [Kitchen - Red].push() (39ms)
+197ms ║║Executed [Kitchen - Red].push (40ms)
+203ms ║║Sending internal web request to: 192.168.1.231:5005/Kitchen%20Play1/state
+205ms ║║Executed virtual command [Kitchen - Red].httpRequest (3ms)
+206ms ║║Requesting a wake up for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 20.0s)
+210ms ║╚Execution stage complete. (85ms)
+211ms ║Setting up scheduled job for Fri, Dec 22 2017 @ 12:54:48 PM EST (in 19.995s)
+218ms ╚Event processed successfully (218ms)