cristian5th / homebridge-appletv

Configuration of pyatv and cmd4 for reading the Apple TV status in Homebridge
GNU General Public License v3.0
25 stars 2 forks source link

Video State #4

Closed m4rkv5 closed 2 years ago

m4rkv5 commented 2 years ago

Here is an additional video playing status:

'Apple TV Movie State')
         case $characteristic in
            'On')
               # Get Apple TV play status
               ATV_PLAYING=$(atvremote --id ${ATV_id} --airplay-credentials ${airplay_credentials} playing )
               ATV_PLAYING_STATE=$(echo "$ATV_PLAYING" | grep -oP '(?<=Device state: ).*')
               ATV_PLAYING_MOVIE=$(echo "$ATV_PLAYING" | grep -oP '(?<=Media type: ).*')
               if [ "${ATV_PLAYING_STATE}" = "Playing" ]
               then
                      if [ "${ATV_PLAYING_MOVIE}" = "Video" ]
                      then
                         printf "1\n"
                      else
                         printf "0\n"
                      fi
               else
                     printf "0\n"
               fi
               exit 0
               ;;
            *)
               printf "UnHandled Get ${device}  Characteristic ${characteristic}\n"
               exit -1
               ;;
         esac
         exit 0
         ;;

Set command can be copied from 'Apple TV Playing State'

cristian5th commented 2 years ago

This is clever. You will get the switch activated only when playing some video and not when playing music. I have added this to the code with #6

Thanks a lot.