LinuxMCE Forums
General => Users => Topic started by: trippleg on November 15, 2011, 08:55:22 pm
-
I am modifying the following code and I can not figure out how to get the template id for the child I am sending the command to. I added childtype, but I fear it is incorrect. I need the template id because the command to send it a little different from the default command.
#### Written by Dan Damron
#### #760 Send Command to Child ####
@insteonID = id.chomp.split('.')
@parameters = parameters
@command = pk_command
@cmd = cmd
childtype =device_.childdevices_[cmdTo].devtemplid_ # find out device type
log('#760:id=' + id.inspect)
log('#760:parameters=' + parameters.inspect)
log('#760:pk_command=' + pk_command.inspect)
log('#760:cmd=' + cmd.inspect)
### ok, I get the insteonID in @insteonID
# pk_command has one of THREE values, 192, 193, or NOTHING
# when I click 50%, I get in parameters: 76
# but NOTHING in pk_command.
case pk_command
when '193' #OFF
when childtype == 4 #used when Device is Thermostat
param = {'Command' => 'SndIns',
'Parameter1' => @insteonID[0],
'Parameter2' => @insteonID[1],
'Parameter3' => @insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B',
'Parameter6' => '09'} #OFF
when childtype != 4 #used when Device not Thermostat
param = {'Command' => 'SndIns',
'Parameter1' => @insteonID[0],
'Parameter2' => @insteonID[1],
'Parameter3' => @insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '13', #OFF
'Parameter6' => '00'}
$cmdqueue << param
SndIns()
Thanks.
-Gregg
-
I have this code in the Tellstick code:
cmdTo = cmd.devidto_ # Device ID in LinuxMCE
devPort = device_.childdevices_[cmdTo].devdata_[12] # 12 contains a port/channel
childType = device_.childdevices_[cmdTo].devtemplid_ # Template ID to know type of device
Hope it helps.
/Joakim
-
I have this code in the Tellstick code:
cmdTo = cmd.devidto_ # Device ID in LinuxMCE
devPort = device_.childdevices_[cmdTo].devdata_[12] # 12 contains a port/channel
childType = device_.childdevices_[cmdTo].devtemplid_ # Template ID to know type of device
Hope it helps.
/Joakim
Can you tell me what childType returns? Is it numeric, or string. I have the same variable defined above. I am using
when childtype == 4 #used when Device is Thermostat
...
Is this the correct way to use this variable.
Is there a way to test the code prior to placing it into the template?
Sorry for the noob question. I am new to both Linuxmce and Ruby.
-Gregg
-
Sorry, I don't. But try doing a .to_s and output it to a log to see the value.
/Joakim