Tivo 1.1 Protocol - NEW Binding Contribution!

The following code can be used in conjunction with the HabPanel and this binding to create a Search “widget” for the TiVo platform:

The rule simply uses the appropriate commands to navigate to the integrated search pages on the TiVo. In the case of Virgin Media TiVo devices this is accessed by sending the:

  1. TIVO (Home) TELEPORT command

  2. Sending the remote control key press IRCODE number 4 (quick way to navigate TiVo menu items).

  3. Each keystroke for characters A-Z, number 0-9 and space are then sent as individual keystrokes (KEYBOARD).

The menu structure of other TiVo devices may differ, so you may need to amend the initial commands to navigate to the search page on your specific device / menu implementation.

Within the rule are a series of sleep commands Thread::sleep(300), these are added to allow the menu system to complete execution of the command before the next command is set. You may need to tweak these numbers depending on the performance of your device.

Rule code:

// Rules
rule "Search"
when
    Item TiVo_KeyboardStr received command
then
	logInfo("tivo.search","Script started ")
	if (TiVo_KeyboardStr.state != NULL && TiVo_KeyboardStr.state.toString.length > 0) {
		
		// Commands to get us to the Tivo/Home menu and select the search menu using the 'remote'
		// number keys
		sendCommand(TiVo_MenuScreen, "TIVO")
		Thread::sleep(800)
		sendCommand(TiVo_KbdCmd, "NUM4")
		Thread::sleep(800)
		
		var i = 0
		var l = 0
		var char txt = ""
		var srch = TiVo_KeyboardStr.state.toString.toUpperCase
		logInfo("tivo.search"," Searching for: " + srch)
		logDebug("tivo.search"," Search length: " + srch.length)

		while (i < (srch.length)) {
			logDebug("tivo.search"," Loop i=: " + i)
			txt = srch.charAt(i)
			logDebug("tivo.search"," txt: " + txt.toString)
			if (txt.toString.matches("[A-Z]")) {
				// Check for upper case A-Z
				sendCommand(TiVo_KbdCmd, txt.toString)
			} else if (txt.toString.matches(" ")) {
				// Check for Space
				sendCommand(TiVo_KbdCmd, "SPACE")
			} else if (txt.toString.matches("[0-9]")) {
				// Check for numbers 0-9
				l = 0
				switch txt.toString {
					case "1":
						sendCommand(TiVo_KbdCmd, "NUM1")
					case "7": {
						sendCommand(TiVo_KbdCmd, "NUM7*5")
						}
					case "9": {
						sendCommand(TiVo_KbdCmd, "NUM9*5")
						}
					default: {
						sendCommand(TiVo_KbdCmd, "NUM" + txt.toString + "*4")
						}
				}
			} else {
				logWarn("tivo.search"," Character not supported by script: " + txt)
			}
			i = i + 1
		}
	}
	lock.unlock()
end

Items:

String 		TiVo_ChangeScreen		"Screens" 			{channel="tivo:sckt:Living_Room:tivoTeleport", autoupdate="false"}
String 		TiVo_IRCmd				"Ir Cmd" 		    {channel="tivo:sckt:Living_Room:tivoIRCommand", autoupdate="false"}
String 		TiVo_KbdCmd				"Keyboard Cmd"   	{channel="tivo:sckt:Living_Room:tivoKBDCommand", autoupdate="false"}

String 		TiVo_KeyboardStr		"Search String"

HABpanel template widget HTML:

  <div class="form-group">
    <div class="col-xs-9">
       <input type="text" class="form-control" style="color: black" no-snap-drag="true" ng-model="myvalue" name="searchStr" required ng-trim="true">
    </div>
    <div class="col-xs-2">
      <button class="btn btn-primary" ng-click="sendCmd('TiVo_KeyboardStr', myvalue)">
		  Search
	   </button>
     </div>
  </div>