I should point out another issue I must of had missed. It turns out channel 32 will only type the 3 when you use that command. It doesnt seem to type the 2. That is a problem in my scenario as there is a 30.1 channel in chicago. So I was spending all night trying to figure out the best way to make different commands for each channel ID. This is what I came up with as I cant figure out the exact syntax for putting bc (the basic calculator command that makes decimals possible) as bash only supports float point integers. I did try to make the number a string but then $channelID has to be a string too for that to work as bash is limited.
bmitune.sh
#!/bin/bash
#bmitune.sh for zinwell/livetv
#2025.01.26
#Debug on if uncommented
set -x
#Global
channelID="$1"
streamerIP="$2"
adbTarget="adb -s $streamerIP"
#Trap end of script run
finish() {
echo "bmitune.sh is exiting for $streamerIP with exit code $?"
}
#Tuning is based on channel number values from zinwell.m3u
tuneChannel() {
if [[ $channelID == 32 ]]; then
$adbTarget shell input keyevent KEYCODE_3
sleep 1
$adbTarget shell input keyevent KEYCODE_2
sleep 1
$adbTarget shell input keyevent KEYCODE_DPAD_CENTER
fi
if [[ $channelID == 2 ]]; then
$adbTarget shell input text $channelID
sleep 1
$adbTarget shell input keyevent KEYCODE_DPAD_CENTER
fi
if [[ $channelID == 5 ]]; then
$adbTarget shell input text $channelID
sleep 1
$adbTarget shell input keyevent KEYCODE_DPAD_CENTER
fi
}
main() {
tuneChannel
}
main
zinwell.m3u
#EXTM3U
#EXTINF:-1 channel-id="2" channel-number="102.1" tvc-guide-stationid="",
http://{{ .IPADDRESS }}/play/tuner/2
#EXTINF:-1 channel-id="5" channel-number="105.1" tvc-guide-stationid="",
http://{{ .IPADDRESS }}/play/tuner/5
#EXTINF:-1 channel-id="32" channel-number="132.1" tvc-guide-stationid="",
http://{{ .IPADDRESS }}/play/tuner/32