Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shortcut to Switch Source via IPcontrol
#1
There are some great iOS shortcuts posted here by @mvrlondon  https://devialetchat.com/Thread-IP-Contr...#pid105018 but one facet I’m still struggling with that didn’t get covered is changing the source. 

I’m hoping to switch the source to Phono through my Arch with a shortcut. I thought this would do it:

Code:
/ipcontrol/v1/systems/current/sources/{sourceID}/playback/play

Based on this site https://www.technomancer.com/archives/840 which indicates you need to use the source id rather than a nicename like “phono”, so I tracked down that mess of numbers but still no luck. 

Anyone have an example of this working? Am I close?
Reply
#2
Hello @vaguedetails -  fun stuff,  if you have not tried using the /groups/ namespace to select sources it seems to work better for me.  also just noticed if the arch does not have an active source playing into it, the call to set it as a source does not really set it to the active source - that might need more testing. 

but use groups and make sure the arch has an active input is what i see. 

even if just using a single system.  not sure about PHONO on the arch, but do use an ARCH with the API - it's just another source in a GROUP.

the Dialog and Arch come from the GROUP not from the SYSTEMs.

like this:  /groups/current/sources/46e08ebb-909f-4ca2-b79d-6628fa341e0e/playback/play 


[HTTP][POST] Playing source at: http://x.y.w.z/ipcontrol/v1/groups/curre...yback/play
[HTTP][POST] Play source command sent successfully

mostly found the deviceIDs seem to be fairly static (at least until you reset the system perhaps) -- but the SOURCE and GROUP IDS change - and you do need to use the ids you enumerated from '/current' - cache what the devices are called (by IP and DeviceID) then build up the source collection after you connect.  you can get hints about the sources from the type and then use that to cache friendly names for the sources. 

a hardcoded URL might work for a while but eventually it will break. 
I've not tried to figure out when its changing. but it changes enough that a 'static shortcut' with some "ID" needs to be tweaked frequently enough that its 'more reliable' to 'enumerate' and then select what you 'enumerated'

there is an official API reference - Phantom's documentation for piloting them via IP – Devialet Help Center

here is some 'debug' output from an app that i use/wrote (old one is slaCmdr new one is slPhantomRemote )
my api 'rubric' is here =  slPhantomRemote - Devialet Speaker Controller Technical Specification (the namespaces i use with different methods)


Let's list the sources from a cmd line.
below shows corelating the device ids and source ids with 'names' and enumerating sources, then playing the arch digital left then playing the dialog.
this is illustrating the output of mapping the Source IDs and the Device ids to friendly names that i cache.
(i have a configuration file to associate the Device IDs and the Source IDs to strings - and some code to figure it out and fix it it all up when it changes)
but the raw URLs and json is printed.

and found a bug or something interesting - prob by design - when the arch does not have an active source playing the api does not show the source update as playing in the return call.   that needs more testing and is what i find usually with the optical sources, you can't really PLAY them unless (there is a lock) and they are active. 

hth

Lets list the sources

sla>l
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
sla:>(0) :optical ->[5245cc71-87ac-48e9-8197-849b9a0d0a7d]<- on  Right
sla:>(1) :raat ->[fd7db031-f095-46d0-a8cf-d466f6afc221]<- on  Left
sla:>(2) :digital_left ->[46e08ebb-909f-4ca2-b79d-6628fa341e0e]<- on  Arch
sla:>(3) :optical ->[09ebe5fc-2206-4e30-9704-886cf30c8923]<- on  Dialog
sla:>(4) :airplay2 ->[213d2c10-df21-433a-b08f-15ad0608c00a]<- on  Left
sla:>(5) :bluetooth ->[5bf676f9-aada-4ced-9394-9e3bc0c7fddc]<- on  Left
sla:>(6) :optical ->[997b63fd-df4c-44ab-880d-dc7d602c2a77]<- on  Left
sla:>(7) :upnp ->[d0b278b8-03b7-4fa2-8172-42ce60deff7e]<- on  Left
sla:>(8) Confusedpotifyconnect ->[cd4b63df-7626-424d-a897-c88d42e2b906]<- on  Left
sla:> Use (listID) or [SourceID] with PlaySource
sla>

sla:> Use (listID) or [SourceID] with PlaySource
sla>pla 2
[DEBUG] OnPlaySource called - IP:  w . x . y. z :, RNS: groups, Source: 2
trying->> set source by source index
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
[DEBUG] Raw sources JSON: {"sources":[{"deviceId":"a7e4a870-a141-529b-b564-13d71d18fc7c","sourceId":"5245cc71-87ac-48e9-8197-849b9a0d0a7d","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"fd7db031-f095-46d0-a8cf-d466f6afc221","type":"raat"},{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","streamLockAvailable":false,"type":"digital_left"},{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","streamLockAvailable":true,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"213d2c10-df21-433a-b08f-15ad0608c00a","type":"airplay2"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"5bf676f9-aada-4ced-9394-9e3bc0c7fddc","type":"bluetooth"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"997b63fd-df4c-44ab-880d-dc7d602c2a77","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"d0b278b8-03b7-4fa2-8172-42ce60deff7e","type":"upnp"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"cd4b63df-7626-424d-a897-c88d42e2b906","type":"spotifyconnect"}]}
sla:>using playindex (2) as source: 46e08ebb-909f-4ca2-b79d-6628fa341e0e
[HTTP][POST] Playing source at: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources/46e08ebb-909f-4ca2-b79d-6628fa341e0e/playback/play
[HTTP][POST] Play source command sent successfully
[DEBUG] Current state after play source: {"availableOperations":["play"],"metadata":{"album":"","artist":"","coverArtDataPresent":false,"duration":0,"mediaType":"unknown","title":""},"muteState":"unmuted","peerDeviceName":"","playingState":"playing","source":{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","type":"optical"},"streamInfo":{"bitDepth":16,"channels":"2.0","codec":"pcm","lossless":false,"samplingRate":48000,"supported":true},"streamLock":true}
sla>

Now lets play the Dialog (Toslink/SPDIF)

sla:> Use (listID) or [SourceID] with PlaySource
sla>pla 3
[DEBUG] OnPlaySource called - IP:  w . x . y. z :, RNS: groups, Source: 3
trying->> set source by source index
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
[DEBUG] Raw sources JSON: {"sources":[{"deviceId":"a7e4a870-a141-529b-b564-13d71d18fc7c","sourceId":"5245cc71-87ac-48e9-8197-849b9a0d0a7d","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"fd7db031-f095-46d0-a8cf-d466f6afc221","type":"raat"},{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","streamLockAvailable":false,"type":"digital_left"},{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","streamLockAvailable":true,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"213d2c10-df21-433a-b08f-15ad0608c00a","type":"airplay2"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"5bf676f9-aada-4ced-9394-9e3bc0c7fddc","type":"bluetooth"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"997b63fd-df4c-44ab-880d-dc7d602c2a77","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"d0b278b8-03b7-4fa2-8172-42ce60deff7e","type":"upnp"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"cd4b63df-7626-424d-a897-c88d42e2b906","type":"spotifyconnect"}]}
sla:>using playindex (3) as source: 09ebe5fc-2206-4e30-9704-886cf30c8923
[HTTP][POST] Playing source at: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources/09ebe5fc-2206-4e30-9704-886cf30c8923/playback/play
[HTTP][POST] Play source command sent successfully
[DEBUG] Current state after play source: {"availableOperations":["play"],"metadata":{"album":"","artist":"","coverArtDataPresent":false,"duration":0,"mediaType":"unknown","title":""},"muteState":"unmuted","peerDeviceName":"","playingState":"playing","source":{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","type":"optical"},"streamInfo":{"bitDepth":16,"channels":"2.0","codec":"pcm","lossless":false,"samplingRate":48000,"supported":true},"streamLock":true}
sla>


sla>l
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
sla:>(0) :optical ->[5245cc71-87ac-48e9-8197-849b9a0d0a7d]<- on  Right
sla:>(1) :raat ->[fd7db031-f095-46d0-a8cf-d466f6afc221]<- on  Left
sla:>(2) :digital_left ->[46e08ebb-909f-4ca2-b79d-6628fa341e0e]<- on  Arch
sla:>(3) :optical ->[09ebe5fc-2206-4e30-9704-886cf30c8923]<- on  Dialog
sla:>(4) :airplay2 ->[213d2c10-df21-433a-b08f-15ad0608c00a]<- on  Left
sla:>(5) :bluetooth ->[5bf676f9-aada-4ced-9394-9e3bc0c7fddc]<- on  Left
sla:>(6) :optical ->[997b63fd-df4c-44ab-880d-dc7d602c2a77]<- on  Left
sla:>(7) :upnp ->[d0b278b8-03b7-4fa2-8172-42ce60deff7e]<- on  Left
sla:>(8) Confusedpotifyconnect ->[cd4b63df-7626-424d-a897-c88d42e2b906]<- on  Left
sla:> Use (listID) or [SourceID] with PlaySource


Now lets play the Arch digital left. (Optical over RCA/COAX)



sla>pla 2
[DEBUG] OnPlaySource called - IP:  w . x . y. z :, RNS: groups, Source: 2
trying->> set source by source index
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
[DEBUG] Raw sources JSON: {"sources":[{"deviceId":"a7e4a870-a141-529b-b564-13d71d18fc7c","sourceId":"5245cc71-87ac-48e9-8197-849b9a0d0a7d","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"fd7db031-f095-46d0-a8cf-d466f6afc221","type":"raat"},{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","streamLockAvailable":false,"type":"digital_left"},{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","streamLockAvailable":true,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"213d2c10-df21-433a-b08f-15ad0608c00a","type":"airplay2"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"5bf676f9-aada-4ced-9394-9e3bc0c7fddc","type":"bluetooth"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"997b63fd-df4c-44ab-880d-dc7d602c2a77","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"d0b278b8-03b7-4fa2-8172-42ce60deff7e","type":"upnp"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"cd4b63df-7626-424d-a897-c88d42e2b906","type":"spotifyconnect"}]}
sla:>using playindex (2) as source: 46e08ebb-909f-4ca2-b79d-6628fa341e0e
[HTTP][POST] Playing source at: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources/46e08ebb-909f-4ca2-b79d-6628fa341e0e/playback/play
[HTTP][POST] Play source command sent successfully
[DEBUG] Current state after play source: {"availableOperations":["play"],"metadata":{"album":"","artist":"","coverArtDataPresent":false,"duration":0,"mediaType":"unknown","title":""},"muteState":"unmuted","peerDeviceName":"","playingState":"playing","source":{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","type":"optical"},"streamInfo":{"bitDepth":16,"channels":"2.0","codec":"pcm","lossless":false,"samplingRate":48000,"supported":true},"streamLock":true}

notice : because there is nothing ACTIVE on the ARCH its not really the current playing source.  
*23 is the dialog... not the arch.

Now lets play the Dialog (Toslink/SPDIF)


sla>pla 3
[DEBUG] OnPlaySource called - IP:  w . x . y. z :, RNS: groups, Source: 3
trying->> set source by source index
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1204
[DEBUG] Raw sources JSON: {"sources":[{"deviceId":"a7e4a870-a141-529b-b564-13d71d18fc7c","sourceId":"5245cc71-87ac-48e9-8197-849b9a0d0a7d","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"fd7db031-f095-46d0-a8cf-d466f6afc221","type":"raat"},{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","streamLockAvailable":false,"type":"digital_left"},{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","streamLockAvailable":true,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"213d2c10-df21-433a-b08f-15ad0608c00a","type":"airplay2"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"5bf676f9-aada-4ced-9394-9e3bc0c7fddc","type":"bluetooth"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"997b63fd-df4c-44ab-880d-dc7d602c2a77","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"d0b278b8-03b7-4fa2-8172-42ce60deff7e","type":"upnp"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"cd4b63df-7626-424d-a897-c88d42e2b906","type":"spotifyconnect"}]}
sla:>using playindex (3) as source: 09ebe5fc-2206-4e30-9704-886cf30c8923
[HTTP][POST] Playing source at: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources/09ebe5fc-2206-4e30-9704-886cf30c8923/playback/play
[HTTP][POST] Play source command sent successfully
[DEBUG] Current state after play source: {"availableOperations":["play"],"metadata":{"album":"","artist":"","coverArtDataPresent":false,"duration":0,"mediaType":"unknown","title":""},"muteState":"unmuted","peerDeviceName":"","playingState":"playing","source":{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","type":"optical"},"streamInfo":{"bitDepth":16,"channels":"2.0","codec":"pcm","lossless":false,"samplingRate":48000,"supported":true},"streamLock":true}
sla>

now let's start something playing INTO the arch and set the group to play the arch.

sla:> Use (listID) or [SourceID] with PlaySource
sla>pla 2
[DEBUG] OnPlaySource called - IP:  w . x . y. z :, RNS: groups, Source: 2
trying->> set source by source index
[HTTP][GET] Getting raw sources from: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources
[DEBUG] Raw sources JSON length: 1203
[DEBUG] Raw sources JSON: {"sources":[{"deviceId":"a7e4a870-a141-529b-b564-13d71d18fc7c","sourceId":"5245cc71-87ac-48e9-8197-849b9a0d0a7d","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"fd7db031-f095-46d0-a8cf-d466f6afc221","type":"raat"},{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","streamLockAvailable":true,"type":"digital_left"},{"deviceId":"c8a05c46-3fc0-5111-aa47-56126ffd2d5a","sourceId":"09ebe5fc-2206-4e30-9704-886cf30c8923","streamLockAvailable":true,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"213d2c10-df21-433a-b08f-15ad0608c00a","type":"airplay2"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"5bf676f9-aada-4ced-9394-9e3bc0c7fddc","type":"bluetooth"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"997b63fd-df4c-44ab-880d-dc7d602c2a77","streamLockAvailable":false,"type":"optical"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"d0b278b8-03b7-4fa2-8172-42ce60deff7e","type":"upnp"},{"deviceId":"e6e97c6f-0ac8-5a35-b68d-52f70cef57af","sourceId":"cd4b63df-7626-424d-a897-c88d42e2b906","type":"spotifyconnect"}]}
sla:>using playindex (2) as source: 46e08ebb-909f-4ca2-b79d-6628fa341e0e
[HTTP][POST] Playing source at: http:// w . x . y. z ::80/ipcontrol/v1/groups/current/sources/46e08ebb-909f-4ca2-b79d-6628fa341e0e/playback/play
[HTTP][POST] Play source command sent successfully
[DEBUG] Current state after play source: {"availableOperations":["play"],"metadata":{"album":"","artist":"","coverArtDataPresent":false,"duration":0,"mediaType":"unknown","title":""},"muteState":"unmuted","peerDeviceName":"","playingState":"playing","source":{"deviceId":"9127538b-79cc-56db-84f1-09807255ec7f","sourceId":"46e08ebb-909f-4ca2-b79d-6628fa341e0e","type":"digital_left"},"streamInfo":{"bitDepth":16,"channels":"2.0","codec":"pcm","lossless":false,"samplingRate":48000,"supported":true},"streamLock":true}

notice how it actually changed that time. id *e0e is playing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)