T5 Question

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • madito
    Extension Master
    • 03.07.2017
    • 131

    #1

    T5 Question

    Today I had an idea using the function "Exit room X" to simulate Loxone's original operation, I use the memory flag "Exit room X" to place it in parallel to the virtual exit T5_DC everything seemed to go well , when making a double click in the center, the music and the light shutdown, but I discovered that if I double click on the center again, the music would sound again.

    Delete a part of the programming and leave it as its original format and although I pulse several times the T5_DC this does not happen.

    I am doing something wrong?

    Thank you!!
  • hismastersvoice
    Supermoderator
    • 25.08.2015
    • 7319

    #2
    At the beginning of the T5 I tought it`s a good idea if the Player starts also with double click.
    Now I have done the same like you, with the function leaving room/home.
    So I changed the code that the player wont start anymore with other than "Single-Click T2"

    You can put the code in /opt/music_server_sqt5 and restart the t5 with sc t5 restart or in the WebUI
    Than It should work...

    Also you can use STOP_ALL in a virtual output to stop all players when leaving the house.

    Code:
    #!/bin/bash
    
    #Config-Files - Read
    source "/opt/music_server/sq_cfg/sq_lms.cfg"
    source "/opt/music_server/sq_cfg/sq_t5.cfg"
    source "/opt/music_server/sq_cfg/sq_zones.cfg"
    source "/opt/music_server/sq_cfg/sq_zones_ext.cfg"
    
    #Variable
    timeout="10"
    
    #Player--Config-Files - Read
    i="1"
    while [ $i -le $SLM_ANZAHL ]
    do
    #Player-Intern
    if [ $i -le "9" ]; then
    source "/opt/music_server/sq_cfg/zones/sq_zone_0"$i".cfg"
    elif [ $i -ge "10" ]; then
    source "/opt/music_server/sq_cfg/zones/sq_zone_"$i".cfg"
    fi
    i=`expr $i + 1`
    done
    i="1"
    while [ $i -le $SLM_ANZAHL_EXT ]
    do
    #Player-Extern
    if [ $i -le "9" ]; then
    source "/opt/music_server/sq_cfg/zones_ext/sq_zone_ext_0"$i".cfg"
    elif [ $i -ge "10" ]; then
    source "/opt/music_server/sq_cfg/zones/sq_zone_ext_"$i".cfg"
    fi
    i=`expr $i + 1`
    done
    
    #Player-Mac-Address - Read
    mac_array_int=()
    i=1
    while [ $i -le $SLM_ANZAHL ]
    do
    mac_array_int+=(${SLM_MAC_ADDRESS[$i]})
    ((i++))
    done
    mac_array_ext=()
    i=1
    while [ $i -le $SLM_ANZAHL_EXT ]
    do
    mac_array_ext+=(${SLM_MAC_ADDRESS_EXT[$i]})
    ((i++))
    done
    
    play_fav(){
        count_pl=$(printf "$mac playlist tracks ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')    
        if [ $count_pl == 1 ];then
        output=$(printf "$mac  favorites playlist play item_id:$fav \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        output=$(printf "$mac playlist index -1 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        else
        output=$(printf "$mac  favorites playlist play item_id:$fav \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        fi
    }
    
    #Function Say_Favorite
    say_fav(){
    for ((i=0; i < ${#mac_array_int[@]}; ++i)); do
        if [ "$mac" = "${mac_array_int[$i]}" ]; then
            zone_location="int"
            zone_index=`echo "scale=0; $i + 1" | bc`
        fi
    done
    
    for ((i=0; i < ${#mac_array_ext[@]}; ++i)); do
        if [ "$mac" = "${mac_array_ext[$i]}" ]; then
            zone_location="ext"
            zone_index=`echo "scale=0; $i + 1" | bc`
        fi
    done
    
    if [ "$zone_location" == "int" ]; then 
    url_zone="&zone=$zone_index&zone_ext=0"
    fi
    if [ "$zone_location" == "ext" ]; then     
    url_zone="&zone=0&zone_ext=$zone_index"
    fi
    
    output=$(printf "$mac stop \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
    vol=$(printf "$mac mixer volume ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')
    vol=`echo "scale=0; $vol + $T5_SAY_FAV_VOL" | bc`
    output_fav=$(awk -F 'text="' '{print $2}'  /var/lib/squeezeboxserver/prefs/favorites.opml | cut -d'"' -f1 | sed -e 's/ /+/g')
    IFS=$'\n' read -rd '' -a favname <<<"$output_fav"
    url="http://$LMS_IP/event/event.php?type=tts&text=${favname[$fav]}$url_zone&vol=$vol&overlay=0"
    curl -s -X GET $url > /dev/null
    }
    
    #Checki if socat for T5 already active
    pid_socat=$(ps -eo pid,command | grep "socat - udp4-listen:$T5_UDP_PORT" | grep -v grep | awk '{print $1}')
    if [ "$pid_socat" > "0" ]; then
    kill -9 $pid_socat
    sleep .2
    fi
    
    #Start Loop / Wait for Command
    socat - udp4-listen:$T5_UDP_PORT,reuseaddr,fork | while read COMMAND
    do
    command_arr=()
    IFS=' ' read -a command_arr <<< "$COMMAND"    
        com=${command_arr[0]}
        mac=${command_arr[1]}
    
    #Check/Read Fav Files
        fav_file="/opt/music_server/sq_fav/$mac"
        if [ ! -e $fav_file ]; then
        fav=1
        echo $fav > $fav_file
        elif [ ! -s $fav_file ]; then
        fav=1
        echo $fav > $fav_file
        else
        fav=$(cat "$fav_file")
        if [ $fav == 0 ];then 
        fav=1
        echo $fav > $fav_file
        fi
        fi
    
    #Chekc if Player Power is 0/1    
    playerPower=$(printf "$mac power ?\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $3}')    
    
    #T2 Single_Click    #Play / Volume +
        if [ $com == "T2_SC" ]; then 
        if [ $playerPower == 0 ]; then
        count_pl=$(printf "$mac playlist tracks ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')    
        if [ $count_pl == 0 ]; then
        if [ $T5_SAY_FAV = 1 ];then say_fav; fi
        play_fav
        else
        play_fav
        fi
        fi
        if [ $playerPower == 1 ]; then
        output=$(printf "$mac mixer volume +$T5_VOLUME_STEP \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        fi
        fi
    
    #T2 Double_Click    #Fav +    
        if [ $com == "T2_DC" ]; then 
        if [ $playerPower == 1 ]; then
        count=$(printf "$mac favorites items 1\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | sed 's/.*3A//' )
        fav=`echo "scale=0; $fav + 1" | bc`
        if [ $fav -lt $count ];then
        if [ $T5_SAY_FAV = 1 ];then say_fav; fi
        play_fav
        else
        fav=1
        if [ $T5_SAY_FAV = 1 ];then say_fav; fi
        play_fav
        fi
        echo $fav >$fav_file
        fi
        fi
    
    #T2 Triple_Click    #Fav -
        if [ $com == "T2_TC" ]; then
        #Fav -
        if [ $playerPower == 1 ]; then
        count=$(printf "$mac favorites items 1\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | sed 's/.*3A//' )
        fav=`echo "scale=0; $fav - 1" | bc`
        if [ $fav -lt 1 ];then
        fav=`echo "scale=0; $count - 1" | bc`
        if [ $T5_SAY_FAV = 1 ];then say_fav; fi
        play_fav
        else
        if [ $T5_SAY_FAV = 1 ];then say_fav; fi
        play_fav
        fi
        echo $fav >$fav_file
        fi
        fi    
    
    #T5 Single_Click    #Volume -
        if [ $com == "T5_SC" ]; then
        #Volume +
        if [ $playerPower == 1 ]; then
        output=$(printf "$mac mixer volume -$T5_VOLUME_STEP \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        fi
        fi
    
    #T5 Double_Click    #Stop
        if [ $com == "T5_DC" ]; then
        if [ $playerPower == 1 ]; then
        output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
        fi
        fi
    
    #T5 Triple_Click
    
    #other Commands
    #Stop all Players
    if [ $com == "STOP_ALL" ]; then
    for mac in "${mac_array_int[@]}"
    do
        output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
    done
    
    for mac in "${mac_array_ext[@]}"
    do
        output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
    done
    fi
    
    if [ $com == "SAY_FAV" ]; then
    if [ $playerPower == 1 ]; then
    say_fav
    play_fav
    fi
    fi
    
    done
    Kein Support per PN!

    Kommentar

    • madito
      Extension Master
      • 03.07.2017
      • 131

      #3
      All work perfect, tomorrow I try STOP_ALL, thanks for the quick solution!

      Kommentar

      • hismastersvoice
        Supermoderator
        • 25.08.2015
        • 7319

        #4
        Fortunately I had the same idea at the same time...
        ...so the solution was ready.
        Kein Support per PN!

        Kommentar

        Lädt...