Premise $14 RF remote (for dvd, tv, aux) for premise

Motorola Premise

etc6849

Senior Member
I think this is pretty neat so I thought I'd share it. After help from 123's x10 threads I decided to get an MR26A, but I couldn't find one by itself, so I ended up getting a remote set VK62A = UR81A remote + MR26A receiver found here: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewI...em=220284866851

The neat thing about the remote set is the hex commands are very similar to the UR47A found in Premise under the Devices/X10/MR26A (with X10 add in installed).

I followed 123's lead in this thread:
http://www.cocoontech.com/forums/index.php?showtopic=9816

I inherited the keypaddevice class to the UR47A (you also need to set the keypadDevice class to virtual before hand so that it is browsable)! See the linked post above for more detailed instructions if you want to use the HR12A as a keypad too.

For the UR47A:
1. Click on the UR47A instance under the MR26.
2. Using the tree control on the left, navigate to Schema/Device/Keypads/KeypadDevice.
3. In the properties window, check the "virtual" property to make it true. (This allows this class to be added as a base class to other classes.)
4. Navigate back to the "UR47A" class. (you can use the back arrow in the toolbar)
5. In click on the center pane. This step is only needed to get the focus on the center pane for the next step.
6. While holding "Ctrl" and "Shift" at the same time, press the "A" key. (i.e. ctrl-shift-A). A message box pops up saying that "expert mode" has been enabled. This is necessary for the next step. Click OK.
7. Right-click in the center pane and select "New|Relationship|Inherited Class".
8. A dialog comes up. Navigate to "Schema|Device|Keypads|KeypadDevice" and press OK. (Note: if you mess up, you can't delete it and you will need to reset the server or go edit the slserver.xdo file manually. Luckily, you can also remove the X10 add in, then re add it. You can also try renavigating to the keypad class too. Any of these three are options)
9. Press ctrl-shift-A to turn off expert mode.

Then I was able to add a new keypad to home and initialize it to the UR47A and all the buttons showed up. The neat thing here is that the UR47A can easily become the readily available UR81A. Almost all the codes are the same except for 5 buttons, 3 of which have the same code, just a different name (ie "C" button etc...). Codes can be learned using the UR47A property page.

To use the UR81A remote with Premise, be sure it is in "PC" mode. It appears this enables the RF communication. The TV, VCR modes seem to only use the IR communication. This doesn't matter for a premise installation though because code can be written to use the AV current source property and send whatever command received by the MR26A to the currently selected device. For example, if I hit play on the UR81A, I'm going to program Premise to send a play command to the current source on the AV receiver; thus play will be sent to the DVD player or the HD DVD player or VMC depending on what the AV receiver is set too.

The cheap UR81A is working 30 feet away through walls (could be more but my apartment is only 30 feet long). 123 also suggests this mod to improve MR26A distance: http://www.shed.com/tutor/mr26ant.html
 
I've added generic code as a subroutine that lets a user send a command and commandvalue to whichever device is selected on the AV receiver. If you want to use it, just import it under modules/default/globalScripts

For example, code might be: sendCommandToCurrentSource "TransportCommand", 1

To play whatever device is selected as the AV receiver input.

Sub sendCommandToCurrentSource(commandName, commandValue)
'Create object collection to populate
Set oRcvrCollection = Home.GetNewObjectCollection

'Add all Receiver objects in the Home to the Object Collection
For Each obj In Home.GetObjectsByType(Schema.Device.AudioVideo.Home.Receiver.Path)
oRcvrCollection.Add obj
Next

'get the first receiver object
Set objRcvr = Home.GetObject(oRcvrCollection(0).Path)

'get the device connected to the current source
Set currentDevice = objRcvr.CurrentSource.Source

'sys.Devices.CustomDevices.VistaMediaCenter.Path
If currentDevice is Nothing Then

Else
'check and make sure property exists for particular device
For Each objProperty In CurrentDevice.GetProperties()
If commandName = objProperty.name Then
CurrentDevice.SetValue objProperty.Name, commandValue
End If
Next
End If
Set objRcvr = Nothing
Set objProperty = Nothing
Set oRcvrCollection = Nothing
Set currentDevice = Nothing
End Sub
 

Attachments

  • sendCommandToCurrentSource.zip
    1 KB · Views: 11
Just a few comments on the code ...

You've grasped many of Premise's advanced scripting techniques but I don't think all of them are needed in this script. The script creates an empty collection, fills it with all Receiver objects found throughout the Home, and then processes the first receiver.

If you want to iterate through Receivers in the Home (or any particular type of object in the Home) you don't need to create an empty collection and then fill it with the desired objects. For example, this will iterate through all lights in the Home and turn them off:
Code:
for each obj in Home.GetObjectsByType(Schema.Device.Lighting.Lighting.Path)
	obj.PowerState = false
next
If there are no lights in the Home, the for-next loop performs zero iterations.


In your script you build a collection of Receivers and then act on the first Receiver in the collection. If you have two Receivers, one in the Family Room and another in the Living Room, there's no guarantee that the Family Room Receiver will always be the first Receiver in the collection. Since the script acts on only one receiver, you might as well reference it explicitly in the script (i.e. something like set objRcvr = Home.Kitchen.MediaZone.Receiver) or pass it, by reference, as a function argument (Sub sendCommandToCurrentSource(ReceiverObject, commandName, commandValue).


Instead of this:
Code:
	If currentDevice is Nothing Then
		' Nothing happens here
	Else
		'check and make sure property exists for particular device
Do this:
Code:
	If not currentDevice is Nothing Then
		'check and make sure property exists for particular device

This is a subtle point but this convention is odd:
If commandName = objProperty.name Then
It is more common to do this:
If objProperty.name = commandName Then
 
Hi 123. Thanks for the feedback and mentor ship. I see what you are saying on the receiver. I wish there was a good alternative to home.theater.avdevices.receiver as one time I changed the room name to theater, and had to modify a bunch of code! The easy solution here would be to do what you suggest: Sub sendCommandToCurrentSource(ReceiverObject, commandName, commandValue).

My thinking is my "theater" will always be the first item under home, so it should always return the receiver in the theater (I think?). I only have one receiver hooked up now, so I'm not sure what would happen if I had two either...

I like shortening the if statement. Good catch. I wish I would've thought of that!

Next I want to implement room occupancy by setting the house code on various HR12a's like you have done. I'm thinking I'll use more subroutines to do this and the occupancy module too, but I'll have to read a lot to figure it out.
 
Back
Top