|
Hardware Support Discussions related to using various hardware setups with SageTV products. Anything relating to capture cards, remotes, infrared receivers/transmitters, system compatibility or other hardware related problems or suggestions should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Issue IR command to USBUIRT when tuner is no longer in use?
Hi all
Yes, still on Sage. I have 4 x Colosus and 4 x Uverse STB's - as some of you may be aware, they shut down into a standby mode after a few hours, I've found success with the published STBKeepAlive, as well as just scheduling tasks at 4 or so hour intervals to use UUTX to send IR for "OK" to all channels of both USBUIRT's. I played with things, and intentionally powered off (to standby) all STB's, and added in the tuner script an "OK" for the specific STB's IR port with a small delay before issuing the padded 4-digit CH#. Problem is, with 4 STB's on all the time, my internet speeds are degraded as the !$*@()$!@)ers don't tell you that every IPTV stream eats into your internet connection. Which brings me to my next point - is there some way to hook into an event or something (even as simple as a batch file with a parameter with the tuner #, or a batch file for each tuner), that powers the STB off (to standby, there is no "off" I guess) when it is no longer needed for recording or LiveTV? |
#2
|
|||
|
|||
Yes, this is doable, but things like this are never 100% reliable. I do this for my satellite STBs because my provider's firmware is so garbage on these boxes that keeping them on 24x7 seems to cause them to lock up every few weeks (or more frequently than that).
How do I do this? Well I have a script that talks to Sage and if there's more than 2 hours before the next scheduled recording and no one is connected to the server then I power down all the STBs connected to Sage. If there's less than 2 hours before a scheduled recording or a client/extender is connected then I leave them on. Basically this usually results in my STBs being in the "off" state for 10-14 hours a night. As I said, it isn't perfect because I maintain the state of the STBs in a file and if something happens such that the state is wrong (namely a power outage) then everything goes backwards. However, this is ok for me because in that case I was going to lose recordings anyways and would need to go down to the basement and power on the STBs manually anyway. For me, I just do it all or none, not tuner by tuner. Why? Because you can't control when Sage wants to grab onto a tuner (or which one) -- Sage runs on the assumption that all STBs are on 24x7 so this is why I control them all together and also why I always turn them all back on when someone connects to the server (again a user may suddenly watch live tv or schedule an immediate recording and Sage expects the STB to be on and functioning when it tries to change channels, etc.). Anyway, with all that, the script I use is an SJQ script, but you could write a similar one that could run standalone and talk to the sagex-remote apis, which is what I use to determine when recordings are scheduled, etc. I've pasted in the groovy script I run from SJQ. I call it once an hour (and SJQ automatically calls it for me everytime a client or extender connects/disconnects to the server). Even if you don't use SJQ, the logic should be useful if you try to write your own. Good luck! file: stb_pwr_mgr.groovy Code:
import sagex.api.* import sagex.SageAPI import sagex.remote.rmi.RMISageAPI import com.google.code.sagetvaddons.groovy.api.GlobalHelpers final def RC_CMD = 'POWER' final def REMOTES = ['SCSD1', 'SCSD5'] final def SAGE_PROP = 'slugger/stbState' def lockCreated = false def lck = new File(new File(System.getProperty('java.io.tmpdir')), '.stb.lck') try { lockCreated = lck.createNewFile() if(!lockCreated) { println 'Unable to create lock; exiting!' throw new IOException("Failed to create lock! [$lck]") } SageAPI.setProvider(new RMISageAPI('192.168.0.133')) def state = Configuration.GetServerProperty(SAGE_PROP, 'true').toBoolean() println "STBs are currently ${state ? 'ON' : 'OFF'}" if(flipState(state)) { REMOTES.each { def rcName = it println "Flipping state for $it" // Find the remote/plugin combo to issue the IR commands to based on the given remote name def found = false for(def plugin : Configuration.GetInfraredTuningPlugins()) { for(def remote : Configuration.GetRemotesForInfraredTuningPlugin(plugin, 0)) { if(remote.equals(rcName)) { found = true issueIrCommand(plugin, remote, RC_CMD) break } } if(found) break } if(!found) { println "Remote '$rcName' is not defined in the system!" } else println "Power toggled to '$rcName' successfully!" } Configuration.SetServerProperty('slugger/stbState', Boolean.toString(!state)) } else println 'Not time to flip the state of the STBs!' return 0 } finally { if(lockCreated) { if(lck.delete()) print 'Lock deleted successfully!' else print 'FAILED to remove lock!' } else print 'Lock was NOT created!' println " [$lck]" } // Given a remote plugin name, the remote ID and the command, issue that command via IR def issueIrCommand(plugin, remote, cmd) { if(cmd ==~ /\d+/) // Assuming each number is an individual command; anything else is a single command name to be issued cmd = cmd.getChars() else cmd = [cmd] for(def c : cmd) { Global.TransmitCommandUsingInfraredTuningPlugin(plugin, 0, remote, String.valueOf(c), 2) sleep Configuration.GetButtonDelayForInfraredTuningPlugin(plugin, 0, remote) } } def flipState(def curState) { if(GlobalHelpers.isAnythingConnected()) { if(!curState) { println 'STBs are off, but someone is connected... turning them back on.' return true } else { println 'Someone is connected; never turn off STBs while someone is connected!' return false } } if(GlobalHelpers.isSomethingRecording()) { if(!curState) { println 'STBs are off, but a recording running!! Turning them back on!!' return true } else { println 'Something is recording; never turn off STBs while recording!' return false } } // Otherwise, turn 'em on within 2 hrs of next recording or turn 'em off if more than 2 hours before next recording def eta = GlobalHelpers.getSecondsUntilNextRecording() println "Time until next recording: ${Utility.PrintDurationWithSeconds(eta * 1000L)}" if(curState) { // They're on, check to see if we should turn them off return eta > 7200 // 2 hours } else { // They're off, check to see if we should turn them on return eta < 7200 } }
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#3
|
|||
|
|||
Looks like a good start... let me add a wrinkle - I have (2) dual tuner HDHR's for recording local OTA programming, so my STB's are free to record non-free stuff. Is there any way to get it to ignore recording/LiveTV state of these other 4 tuners?
Also, any particular reason for the 2 hours' padding? Wouldn't 15 minutes or a half an hour be enough for our purposes? I am dealing with the motorola VIP series, so their "Off" is actually the same as the time out "sleep" state. I can send an OK as a channel change prefix and it will pop on quick enough to accept the digits and tune.... Is there any event handler for when a recording (scheduled or LiveTV) ends? (Akin to I would imagine how ComSkip gets called upon recording completion, or Auto Convert would get called? Every "on" STB in HD (and they all are) eats ~ 8mbits/second per STB, and I've got a 32Mbit line, and 4 STB's, which can take my internet down from 24Mbit down to under 8Mbit. I have one pair synched perfectly at 32mbit, yet AT&T refuses to pair bond me using 2 pairs at 27mbit each, even though a previous tech started the process by replacing the ghastly 2Wire RG with the nice NVG589 bonded pair capable RG. |
#4
|
|||
|
|||
With SJQ you can run a process whenever a recording ends - just for the reason you speculated. So you should be able to modify this script so that when a recording ends it will look to see if any other recordings are taking place. If not then it could power everything down. You could probably do this on a Tuner by tuner basis doing something like
Code:
for each tuner in tunerlist if { tuner is not HDHR if { tuner is not recording then power tuner off } end if } end for
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server |
#5
|
|||
|
|||
Would I be able to do something like this in windows 7 or do I need to have linux? Where do I put the script to get it to run if I am using Sagetv 9?
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
External Command Tuner Plugin for Linux | stuckless | SageTV Linux | 36 | 05-16-2017 03:11 PM |
Music no longer playing issue? | Wxford | SageTV Software | 0 | 09-13-2008 09:24 PM |
One Tuner no longer working | zubblwump | Hardware Support | 5 | 08-17-2006 10:39 PM |
Help getting 'Sage' to issue an IR command | srcurtis | SageTV Software | 5 | 10-06-2005 04:14 PM |
Tune a tuner card with command line? | Naylia | Hardware Support | 2 | 09-19-2005 11:58 AM |