<div dir="ltr">Greetings Mythizens, It seems that since adding the &quot;check_stb&quot; script, that the stb is turned on when Myth or I turn on the PC, which is a good thing because as I&#39;ve read and as my limited experience confirms, The DCT700 needs to be excited first before responding appropriately to IR. Now that the system is setup to turn itself on and off, I&#39;m guessing that another line or so should be added to the &quot;setwakeup.sh&quot; to turn the stb off as a further power saving factor. Can anyone confirm and or direct in this endeavor? Below is &quot;check_stb&quot;<div>
<br></div><div><div>#! /bin/bash</div><div><br></div><div># Authored by Evuraan_AT_gmail_DOT_com</div><div><br></div><div># ABSOLUTELY NO WARRANTY, to the extent permitted by</div><div># applicable law.</div><div><br></div>
<div># YMMV.</div><div># Use at your own risk.</div><div><br></div><div><br></div><div>pvr=&quot;/dev/video0&quot;</div><div>t=&quot;$RANDOM-$RANDOM&quot;</div><div>out=&quot;/tmp/$t.mpg&quot;</div><div>mark=&quot;1727&quot;</div>
<div>blank=&quot;0&quot;</div><div>say=&quot;/usr/bin/logger -p info -t mythstb-check&quot;</div><div>POWEROFF=&quot;0&quot;</div><div>POWERON=&quot;0&quot;</div><div>wakeup=&quot;/usr/bin/irsend SEND_ONCE DCT700 POWER&quot;</div>
<div>info=&quot;/usr/bin/irsend SEND_ONCE DCT700 info&quot;    </div><div><br></div><div><br></div><div><br></div><div>send_power_on() {</div><div>$say &quot;`date` STB seems to be turned off, last count was $blank, attempting to Power it on&quot; &amp;</div>
<div>$wakeup 1&gt;/dev/null 2&gt;/dev/null || :</div><div>sleep 2</div><div>}</div><div><br></div><div>scan_images(){</div><div>for i in `echo /tmp/$t*.jpeg`</div><div>do</div><div>if [ -s &quot;$i&quot; ]</div><div>then</div>
<div>#blank=&quot;`jp2a $i --invert --size=72x24 | sed -e &#39;s/./&amp; \n/g&#39;|grep -c &quot;M&quot;`&quot;</div><div>blank=&quot;`jp2a $i --invert --size=72x24 | sed &#39;s/W/M/g&#39; | sed -e &#39;s/./&amp; \n/g&#39;|grep -c &quot;M&quot;`&quot;</div>
<div> rm -f &quot;$i&quot; 1&gt;/dev/null 2&gt;/dev/null || :</div><div>else</div><div> :</div><div>fi</div><div>[ &quot;$blank&quot; -gt &quot;$mark&quot; ] &amp;&amp; export POWERON=&quot;100&quot;</div><div>[ &quot;$blank&quot; -le &quot;$mark&quot; ] &amp;&amp; export POWEROFF=&quot;100&quot;</div>
<div>done</div><div>if [ &quot;$POWERON&quot; -eq &quot;100&quot; -a &quot;$POWEROFF&quot; -ne &quot;100&quot; ]</div><div>then</div><div># its off</div><div>send_power_on</div><div>else</div><div># power is on, non blank frames</div>
<div>$say &quot;`date` STB seems to be turned on, last count was $blank&quot;</div><div>:</div><div>fi</div><div><br></div><div>}</div><div><br></div><div>purge_stuff(){</div><div>[ -f &quot;$out&quot; ] &amp;&amp; rm -f &quot;$out&quot; 1&gt;/dev/null &gt;/dev/null || :</div>
<div>}</div><div><br></div><div>#ivtv-tune -c 3 -d &quot;$pvr&quot; 1&gt;/dev/null 2&gt;/dev/null &amp;</div><div><br></div><div>cd /tmp</div><div>$info &amp;</div><div><br></div><div>dd if=&quot;$pvr&quot; of=&quot;$out&quot; bs=64K count=2  1&gt;/dev/null 2&gt;/dev/null</div>
<div><br></div><div>if [ -s &quot;$out&quot; ]</div><div>then</div><div>ffmpeg -i $out -f image2 -vcodec mjpeg /tmp/$t%d.jpeg 1&gt;/dev/null 2&gt;/dev/null</div><div>[ -s &quot;/tmp/${t}1.jpeg&quot; ] &amp;&amp; scan_images</div>
<div>else</div><div>$say &quot;`date` Unable to query $pvr, as it seems to be in use.&quot;</div><div>:</div><div>fi</div><div><br></div><div>purge_stuff &amp;</div></div><div><br></div><div>And here is the &quot;setwakeup.sh&quot;</div>
<div><br></div><div><div>#!/bin/sh</div><div>#</div><div># set ACPI Wakeup time</div><div># usage: setwakeup.sh seconds</div><div>#    seconds - number of seconds from epoch to UTC time (time_t time format)</div><div>#</div>
<div># set UTCBIOS to true if bios is using UTC time</div><div># set UTCBIOS to false if bios is using local time</div><div><br></div><div>UTCBIOS=false</div><div><br></div><div>if $UTCBIOS</div><div>then</div><div>    #utc bios - use supplied seconds</div>
<div>    SECS=$1</div><div>else</div><div>    #non utc bios - convert supplied seconds to seconds from</div><div>    #epoch to local time</div><div>    SECS=`date -u --date &quot;\`date --date @$1 +%F&quot; &quot;%T\`&quot; +%s`</div>
<div>fi</div><div><br></div><div>echo 0 &gt; /sys/class/rtc/rtc0/wakealarm    # clear alarm</div><div>echo $SECS &gt; /sys/class/rtc/rtc0/wakealarm   # write the waketime</div><div><br></div><div>LOGFILE=/var/log/mythtv/setwakeup.log</div>
<div>cat /proc/driver/rtc &gt; $LOGFILE</div><div>cat /sys/class/rtc/rtc0/wakealarm &gt;&gt; $LOGFILE</div><div>echo &quot;Argument 1 = $1, SECS = $SECS&quot; &gt;&gt; $LOGFILE</div></div><div><br></div><div>Thanks, Daryl</div>
</div>