Jump to content

- - - - -

Scripting Problem - Setting the Macro TargetProperty in script

  • Please log in to reply
No replies to this topic

#1 123



  • Registered
  • PipPipPipPip
  • 2146 posts
  • Location:Montreal, QC
  • Experience:average
  • Software:Premise
  • Hardware:Elk M1

Posted 07 March 2008 - 11:39 AM

I am writing a new LutronKeypad class for use with Lutron Homeworks. The keypad class that comes with Premise is rather limited when bound to a Lutron keypad device.

Below is some code I use in the INITIALIZE method to populate the Keypad with buttons when added to the UI. The code looks up the bound Lutron Keypad device , scans the Lutron buttons and creates the necessary Button objects under the Keypad.

I am also trying to dynamically create a CommandMacro for each button which toggles the Lutron button trigger property when someone presses the button. Everything works fine except I am having problems setting the TargetProperty on the newly created macro object.

The code executes OK, the buttons are created under the Keypad, and macros are created under each button but the TargetProperty of the macros remains empty.

Any ideas?

Here is the code:

if this.LutronKeypad is nothing then
   this.StatusMessage = "Please set the LutronKeypad property before initializing buttons."

   'Lookup all the buttons of the Lutron Keypad and set their names
   for each oButton in this.LutronKeypad.GetChildren

	  if oButton.Class.Path = "sys://Schema/Lutron/HWI/HWI_Button" then
		 set newButton = this.CreateObject("sys://Schema/Device/Keypads/Button","Button_" & cstr(oButton.ButtonID) )
		 newButton.DisplayName = oButton.DisplayName ' Create the same display name as the Lutron label
		 newButton.BoundObject = oButton 'Create a reference to the button device

		 'Create a macro for each button so that it triggers the device button
		 set oNewMacro = newButton.CreateObject("sys://Schema/System/CommandMacro","CommandMacro" )
		 oNewMacro.TargetObject = oButton
		 oNewMacro.TargetProperty = schema.Device.ButtonTrigger.Trigger
		 oNewMacro.TargetAction = schema.System.Boolean.Toggle

		 set oNewMacro = nothing
		 set newButton =nothing
	  end if

   this.StatusMessage = "Buttons Initialized"
end if

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users