@bnhf
Been awhile but I am working on my scripts for the AppleTV Spectrum setup again...It is still working fantastic overall.
Currently still running bnhf/ah4c:appletv.test2
I have added "select" button press after a delay to clear the overlay on the few occasions it comes up. It doesn't mess anything up if the overlay isn't there... So this was easier than trying to implement tesseract for this.
Added to bmitune.sh file
sleep 45
atvremote --storage-filename /root/.android/.pyatv.conf -s $streamerIP select
I am working on solving 2 additional issues...
- Keep "tuner" running for a predetermined amount of time before completely closing the app. This allows faster tuning when surfing.
- Send key press after so long to keep "Are You Still Watching" from coming up.
Issue 1
I believe I have a solution for the first but am having problems implementing it. When stopbmitune.sh is called I am attempting to run a 2nd script from within it called stopdelay.sh
stopdelay.sh
#!/bin/bash
streamerIP="$1"
echo ""$$"" > /root/.android/$streamerIP.stop.txt
sleep 300
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Killing Feed on ATV "$streamerIP"" >> /root/.android/$streamerIP.txt
atvremote --storage-filename /root/.android/.pyatv.conf -s $streamerIP home delay=250 home delay=5000 up delay=250 up delay=5000 home
This stopdelay.sh script passes the current streamerIP in from stopbmitune.sh. It then records the process number into a file that I use to kill this script in my bmitune.sh script if I tune another channel before the timer shuts down the stream.
All these scripts are located in the scripts directory and have the same attributes including the right to be executed.
Here is the stopbmitune.sh script I am trying to use...
#!/bin/bash
streamerIP="$1"
channelID="$2"
tunekill="$(< /root/.android/$streamerIP.tune.txt)"
kill $tunekill
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Running stopbmitune.sh..." >> /root/.android/$streamerIP.txt
/opt/scripts/atv/spectrum/stopdelay.sh $streamerIP &
I have tried many different versions to run the second script with no luck...
Here are some of them
stopdelay.sh $streamerIP
/opt/scripts/atv/spectrum/stopdelay.sh $streamerIP &
/opt/scripts/atv/spectrum/stopdelay.sh "192.168.1.54" &
/opt/scripts/atv/spectrum/stopdelay.sh $streamerIP
./opt/scripts/atv/spectrum/stopdelay.sh $streamerIP &
/bin/bash /opt/scripts/atv/spectrum/stopdelay.sh $streamerIP
And others I can't remember right now.
I believe I need the & at the end so this script runs but allows the stopbmitune.sh script to finish without waiting for stopdelay.sh to finish. This allows the tuner to be marked as "ready for use" and tune the next channel without waiting.
Also here is the bmitune.sh
#!/bin/bash
channelID="$1"
streamerIP="$2"
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Running bmitune.sh..." >> /root/.android/$streamerIP.txt
echo ""$$"" > /root/.android/$streamerIP.tune.txt
delaykill="$(< /root/.android/$streamerIP.stop.txt)"
kill $delaykill
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Tuning Channel "$channelID" on ATV "$streamerIP"" > /root/.android/$streamerIP.txt
atvremote --storage-filename /root/.android/.pyatv.conf -s $streamerIP launch_app=spectrumTV://watch.spectrum.net/livetv/$channelID
sleep 45
atvremote --storage-filename /root/.android/.pyatv.conf -s $streamerIP select
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Sent Select Command to Clear Menu on ATV "$streamerIP"" >> /root/.android/$streamerIP.txt
sleep 10
title="`atvremote --storage-filename /root/.android/.pyatv.conf -s $streamerIP title`"
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Playing "$title"" >> /root/.android/$streamerIP.txt
sleep 13200
echo ""$(date +"%Y-%m-%d %I:%M:%S%p")" ...Sending Still Watching IR Commands" >> /root/.android/$streamerIP.txt
#No commands sent through atvremote work to stop "Are You Still Watching" from coming up.
#This will be used to send IR commands probably using curl to prevent this instead.
I think I just need to figure out how to run the stopdelay.sh inside of stopbmitune.sh and I will have this. I am not an expert on shell scripts and just can't seem to figure out the right way to do it 
Issue2
IR commands... looking for the best/cheapest way to do this just using something really simple like curl commands from my scripts sent to a microcontroller like ESP8266 or ir hub that can receive curl commands and send to multiple "tuners". Don't want to add a bunch of extra stuff like HomeLab/HomeAssistant. Let me know if anyone has suggestions.