[mythtv-users] Checking power status of STB

Justin Alcorn justin at jalcorn.net
Wed Oct 29 23:45:10 UTC 2014


I was searching for a way to check power status on my STB with a
HDPVR, and I found some very complex scripts that saved a file and
used ffmpeg to see if the frames were blank, couldn't do anything if
the PVR was recording, or firewire-only programs.

But playing around with return codes, on a Ubuntu 14.04.1 server with
MythTV 0.28, this script seems to work perfectly under the following
scenarios:

STB is powered off
STB is powered on
STB is powered on and HDPVR is recording

It can't do anything about the HDPVR being off, but at least I don't
have to worry about the STB being powered off by one of the kids with
the remote.

I run the script every 30 minutes in cron

29,59 * * * * bin/check_power_status.sh

I'm haven't looked to see if I can just run it before every recording.

Anyone see any problems with this?

#!/bin/bash

dev="/dev/video0"
of="/tmp/$$.mpg"
poweron="0_74_KEY_POWER"
remote="blaster"
lircdev="/dev/lircd"
until $(timeout 2 dd if=${dev} of=${of} bs=4k count=1 1>/dev/null 2>/dev/null )
do
        echo "Powering on STB"
        /usr/bin/irsend --device=${lircdev} SEND_ONCE ${remote} ${poweron}
        sleep 10
done
rm ${of}


--
Justin B. Alcorn
PGP Fingerprint A36D D691 C5B0 BE15 5A2A AF49 AA1C 372C


More information about the mythtv-users mailing list