Max2play setup with two or more servers – how to switch server ?

Max2Play Home Forums Max2Play as Squeezebox (Player / Server) Max2play setup with two or more servers – how to switch server ?

Viewing 4 posts - 1 through 4 (of 4 total)
  • 7. Dezember 2022 at 9:41 #52503

    Hi,

    In my setup I have now two sqeezebox servers, both with DAC+ADC PRO in order to stream from the input jack the sound from my smartphone for the first server and TV sound for the second server.

    Using openHap I’ve added my two servers and add two of each players. Once bridged to the normal server and once to the TV server.

    When I group the players it’s working if players are connected to the same server.

    My problem is that the only one way I’ve found to set the current server of a player is using sqeezebox server interface.

    I should connect on the target sqeezebox server interface, click the dropdown list in the upper right corner, select the player.
    Then sqeezebox ask me : „This player is currently connected to <%s>. Do you want it to switch back to Logitech Media Server?

    How could I do this switch from max2play, from an API or from openhab ?

    Thanks

    • This topic was modified 1 year, 11 months ago by Jack Bauer.
    • This topic was modified 1 year, 11 months ago by Jack Bauer.
    8. Dezember 2022 at 13:50 #52514

    Hi Jack,

    You could probably use the Server CLI to do this. The command <playerid> connect <ip> connects a player to a server. You can find more info here: http://htmlpreview.github.io/?https://raw.githubusercontent.com/Logitech/slimserver/public/7.9/HTML/EN/html/docs/cli-api.html#connect

    16. Dezember 2022 at 0:48 #52529

    Hi Mario!

    Thank you very much for your Help !

    I’v managed that tonight!

    If it can help someone :

    I’ve had to create a shell script that I’ll name runTelnetCommand.sh

    
    #!/bin/bash
    
    if [ $1 == "connect" ]
    then
      echo "Send to $4:9090 to connect Player $2 on server $3"
      printf "$2 connect $3\nexit\n" | nc $4 9090 2>/dev/null | cut "-d " -f 3
      echo "Done"
    else
       echo "Unknown command $1"
    fi
    

    I’ve put this script on my openHab volume on path /openhab/userdata/etc/scripts/runTelnetCommand.sh (i’m using a dockerized openhab)
    You just have to put this script somewhere openHab can access it.

    Check it’s runnable with
    chmod +x /openhab/userdata/etc/scripts/runTelnetCommand.sh

    On my docker container I’ve had to install nc which is not packaged

    Connect manually to the container :
    docker exec -it <containerId> /bin/bash
    Install netCat to send telnet commands
    apt-get update && apt-get install -y netcat

    Within my ECMA javascript action for my openHab trigger script I’ve add a exec

    
    var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
    var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
    var Duration = Java.type("java.time.Duration");
    
    var serverScriptPath = '/openhab/userdata/etc/scripts/runTelnetCommand.sh';
    var serverScriptCommand = 'connect';
    
    var mac_room1 = 'aa:bb:cc:dd:ee:ff';
    var mac_room2 = 'ff:ee:dd:cc:bb:aa';
    
    var firstServerIp = '192.168.1.15';
    var secondServerIp = '192.168.1.16';
    
    logger.info("Result connection room1: " + Exec.executeCommandLine(Duration.ofSeconds(20), serverScriptPath, serverScriptCommand, mac_room1, firstServerIp, secondServerIp));
    logger.info("Result connection room2: " + Exec.executeCommandLine(Duration.ofSeconds(20), serverScriptPath, serverScriptCommand, mac_room2, firstServerIp, secondServerIp));
    

    It’s important to send commands to IP’s because DNS names does not seems to work.

    Having those function I can switch players mac_room1 and mac_room2 from server 1 to server 2

    I hope this will help 😉

    • This reply was modified 1 year, 11 months ago by Jack Bauer.
    20. Dezember 2022 at 13:55 #52543

    Hi Jack,

    Thanks for sharing your solution!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Register here