Help with adding action with values
Posted: Mon Nov 26, 2012 1:32 am
Can anyone please help me, by showing me how to pass values to actions? I have been struggling with this for quite some time now, and this will be my last effort before I ditch the whole thing.
For example, I have some code that Fiasco started (and I think it was copied from Bitmonster initially - this is for the RadioRA2 plugin for Lutron), and there is a problem that I cannot solve. Essentially, what happens is, when the plugin gets loaded, it runs through a for loop adding several actions into the tree. The last values of the for loop that were parsed, ends up on ALL the actions. I can't figure out why, and I've exhausted all my searching. Apparently Fiasco was also struggling with this problem, because he put this issue in his original thread for this plugin, but unfortunately, his question/problem went unanswered. If anyone would be kind enough to show the following example:
For a list of values and descriptions:
100, Room A
200, Room B
300, Room C
400, Room D
Show me how to add actions to the tree automatically when the plugin is loaded, and then when the action is executed, how I would be able to access these values that were passed into the action when the action was created (so that I can use the values when I generate traffic out of the tcp port for example). The way the plugin works now, I get all 4 actions created in the tree ok (with the proper value and description), but when the action is executed, they all execute with "400, Room D"
Here is the original post from Fiasco describing the problem:
----------------------------------------------------------------------------------
In the following code within the RadioRa plugin
This is iterated through to build the command list for RA.
The command assigned is in the print statement and I see these iterated through correctly when I add the plugin and it creates the command list.
However, the name of the function always has the first deviceID that is parsed (name = descr + " " + deviceid) and the command that is ultimately called has the deviceid of the last deviceid parsed.
the device ID is always correct in the group name What am I doing wrong?
*Attachment removed - problem resolved - see RadioRA2 Plugin thread for download
Thanks in advance for anyone willing to take the time to help me with this.
For example, I have some code that Fiasco started (and I think it was copied from Bitmonster initially - this is for the RadioRA2 plugin for Lutron), and there is a problem that I cannot solve. Essentially, what happens is, when the plugin gets loaded, it runs through a for loop adding several actions into the tree. The last values of the for loop that were parsed, ends up on ALL the actions. I can't figure out why, and I've exhausted all my searching. Apparently Fiasco was also struggling with this problem, because he put this issue in his original thread for this plugin, but unfortunately, his question/problem went unanswered. If anyone would be kind enough to show the following example:
For a list of values and descriptions:
100, Room A
200, Room B
300, Room C
400, Room D
Show me how to add actions to the tree automatically when the plugin is loaded, and then when the action is executed, how I would be able to access these values that were passed into the action when the action was created (so that I can use the values when I generate traffic out of the tcp port for example). The way the plugin works now, I get all 4 actions created in the tree ok (with the proper value and description), but when the action is executed, they all execute with "400, Room D"
Here is the original post from Fiasco describing the problem:
----------------------------------------------------------------------------------
In the following code within the RadioRa plugin
Code: Select all
if devicetype == 'maestro':
group = self.AddGroup('RadioRa2 Maestro Dimmer/Switch - ' + deviceid + ' ' + devicelocation )
for className, descr, act, pre in MAESTRO_DEVICE_ACTIONS:
print pre + 'OUTPUT,' + deviceid + ',' + act
clsAttributes = dict(
name=descr + ' ' + deviceid,
action=act,
prefix=pre,
deviceid=deviceid,
devicetype=devicetype,
devicelocation=devicelocation,
command = pre + 'OUTPUT,' + deviceid + ',' + act
)
if ( className == "SETZONELEVEL" ):
cls = ClassType(className, (MaestroAction,), clsAttributes)
else:
cls = ClassType(className, (NvAction,), clsAttributes)
group.AddAction(cls)
This is iterated through to build the command list for RA.
The command assigned is in the print statement and I see these iterated through correctly when I add the plugin and it creates the command list.
However, the name of the function always has the first deviceID that is parsed (name = descr + " " + deviceid) and the command that is ultimately called has the deviceid of the last deviceid parsed.
the device ID is always correct in the group name What am I doing wrong?
*Attachment removed - problem resolved - see RadioRA2 Plugin thread for download
Thanks in advance for anyone willing to take the time to help me with this.