This repository was archived by the owner on Jun 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ When this option is set, airsonos skips teh autodiscovery part and tries to conn
3434specified in <device_list>. A Sonos device is specified by its IP.
3535Optionally you can set also its TCP port if the device is set to not use the default port (1400).
3636
37+ As long as airsonos is able to connect to at least one device, it will not end itself.
38+
3739This is the syntax:
3840```
3941airsonos --devices SONOS1_IP[:SONOS1_PORT][,SONOS2_IP[:SONOS2_PORT][,...]]
Original file line number Diff line number Diff line change @@ -110,17 +110,35 @@ if (flags.get('version')) {
110110 diag ( ) ;
111111
112112} else if ( flags . get ( 'devices' ) . length > 0 ) {
113- var useDevices = flags . get ( 'devices' ) ;
114- for ( var i = 0 ; i < useDevices . length ; i ++ ) {
115- var ipPortSplit = useDevices [ i ] . split ( ':' ) ;
113+
114+ var deviceArguments = flags . get ( 'devices' ) ;
115+ for ( var i = 0 ; i < deviceArguments . length ; i ++ ) {
116+
117+ var deviceArg = deviceArguments [ i ] ;
118+
119+ // set up a domain to catch errors from setting up individual
120+ // devices. For example it catches the timeout when non-existing IPs
121+ // are entered.
122+ var setupDomain = require ( 'domain' ) . create ( ) ;
123+ setupDomain . on ( 'error' , function ( err ) {
124+ console . error ( 'Error on setting up device "' + deviceArg + '": ' + err ) ;
125+ } ) ;
126+
116127 var sonosDevice ;
128+
129+ // Check if the argument contains a port specifier
130+ var ipPortSplit = deviceArg . split ( ':' ) ;
117131 if ( ipPortSplit . length > 1 ) {
118132 sonosDevice = new sonos . Sonos ( ipPortSplit [ 0 ] , ipPortSplit [ 1 ] ) ;
119133 } else {
120- sonosDevice = new sonos . Sonos ( useDevices [ i ] ) ;
134+ sonosDevice = new sonos . Sonos ( deviceArg ) ;
121135 }
122136
123- setupSonos ( sonosDevice , 'Sonos' + i ) ;
137+ // run the setup in a domain so we can catch errors for each device
138+ // individually:
139+ setupDomain . run ( function ( ) {
140+ setupSonos ( sonosDevice ) ;
141+ } ) ;
124142 }
125143
126144} else {
You can’t perform that action at this time.
0 commit comments