Difference between revisions of "Insteon PLM Ruby Code 384"

From LinuxMCE
Jump to: navigation, search
(Updated to support X10)
(Added category: GSD)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Versioninfo}}
 +
[[category: Insteon]]
 +
[[Category: GSD]]
 
<pre>#### Written by Dan Damron
 
<pre>#### Written by Dan Damron
 
#### #384 Process Receive Command for Child ####
 
#### #384 Process Receive Command for Child ####
 
#
 
#
 
#Commands needing implementation
 
#Commands needing implementation
# Climate commands:
 
# 279 (Set Fan)
 
# 280 (Set Heat/Cool)
 
# 278 (Set Temperature)
 
 
# Climate Events:
 
# Climate Events:
# 25 Temperature Changed
+
# 25 Temperature Changed Partially working
# 26 Humidity Changed
+
# 26 Humidity Changed     Partially working
# 27 Thermostat Set Point Changed
+
# 27 Thermostat Set Point Changed Partially working
  
 
# Security Commands:
 
# Security Commands:
Line 45: Line 44:
 
$cmdType = cmd.type_
 
$cmdType = cmd.type_
 
$cmdParams = cmd.params_
 
$cmdParams = cmd.params_
 +
##Used Only for Thermostat Tempruature Changes########
 +
$TempParamSplit =cmd.params_.to_s.split('/') # splits Tempurature string to allow for heat and cool settings
 +
$ConvertTempInt = $TempParamSplit[1].to_i * 2
 +
$ConvertTempHex = $ConvertTempInt.to_s(16) #Converts temp to hex to send to Thermostat
 +
#################################
 
log('------dce--- cmdID:' + $cmdID.to_s + ', cmdFrom:' + $cmdFrom.to_s + ', cmdTo:' + $cmdTo.to_s + ', cmdType:' + $cmdType.to_s + ', Priority:' + $cmdPriority.to_s)
 
log('------dce--- cmdID:' + $cmdID.to_s + ', cmdFrom:' + $cmdFrom.to_s + ', cmdTo:' + $cmdTo.to_s + ', cmdType:' + $cmdType.to_s + ', Priority:' + $cmdPriority.to_s)
 
if $cmdTo == $cmdFrom
 
if $cmdTo == $cmdFrom
log('Detected Command sent to Self!')
+
log('Detected Command sent to Self!')
return
+
return
 
end
 
end
case cmd.id_
+
case cmd.id_
when 192 # ON
+
log('Processing ON command')
+
  if insteonID.length > 2 then
+
+
    param = {'Command' => 'SndIns',
+
      'Parameter1' => insteonID[0],
+
      'Parameter2' => insteonID[1],
+
      'Parameter3' => insteonID[2],
+
      'Parameter4' => '0F',
+
      'Parameter5' => '11',
+
      'Parameter6' => 'FF'}
+
    $cmdqueue << param
+
    SndIns()
+
  else
+
    log "------dce--- X10 DEVICE!!!"
+
# Send X10 ON command.
+
#first, figure out the house code and unit code.
+
log('DeviceID=' + deviceID)
+
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
+
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
+
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
+
x10cmd += '2' # command code for ON
+
log('X10 Byte1:' + x10Byte1)
+
param = {'Command' => 'SndX10',
+
        'Parameter1' => x10Byte1,
+
        'Parameter2' => '00'}
+
$cmdqueue << param
+
param = {'Command' => 'SndX10',
+
'Parameter1' => x10cmd,
+
'Parameter2' => '80'}
+
$cmdqueue << param
+
    SndIns()
+
  end
+
  reportStatus($children[deviceID], 100)
+
when 193 #OFF
+
  if insteonID.length > 2 then
+
+
    param = {'Command' => 'SndIns',
+
      'Parameter1' => insteonID[0],
+
      'Parameter2' => insteonID[1],
+
      'Parameter3' => insteonID[2],
+
      'Parameter4' => '0F',
+
      'Parameter5' => '13',
+
      'Parameter6' => '00'}
+
    $cmdqueue << param
+
    SndIns()
+
  else
+
    log "------dce--- X10 DEVICE!!!"
+
log('DeviceID=' + deviceID)
+
  
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
+
when 278 # Set Temp
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
+
log('Processing Temp Control command')
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
+
#log($cmdParams)
x10cmd += '3' # command code for OFF
+
if insteonID.length > 2 then
log('X10 Byte1:' + x10Byte1)
+
case $TempParamSplit[0].to_s
param = {'Command' => 'SndX10',  
+
when '5C' #sending Heatpoint Tempurature
        'Parameter1' => x10Byte1,
+
param = {'Command' => 'SndIns',
        'Parameter2' => '00'}
+
'Parameter1' => insteonID[0],
$cmdqueue << param
+
'Parameter2' => insteonID[1],
param = {'Command' => 'SndX10',
+
'Parameter3' => insteonID[2],
'Parameter1' => x10cmd,
+
'Parameter4' => '0F',
'Parameter2' => '80'}
+
'Parameter5' => '6C', # Defines Cool Setpoint
$cmdqueue << param
+
'Parameter6' => $ConvertTempHex} # send Tempurature Value in Hex
    SndIns()
+
$cmdqueue << param
+
SndIns()
  end
+
 
  reportStatus($children[deviceID], 0)
+
when '5H' #sending Heatpoint Tempurature
when 184 #SetLevel
+
param = {'Command' => 'SndIns',
  # convert from percent to hex
+
'Parameter1' => insteonID[0],
  dim_level = percenttohex(cmd.params_[76])
+
'Parameter2' => insteonID[1],
  #log("------dce--- Dim Level:" + dim_level.to_s)
+
'Parameter3' => insteonID[2],
  if insteonID.length > 2 then
+
'Parameter4' => '0F',
+
'Parameter5' => '6D', # Defines Heat Setpoint
    param = {'Command' => 'SndIns',
+
'Parameter6' => $ConvertTempHex} # send Tempurature Value in Hex
      'Parameter1' => insteonID[0],  
+
$cmdqueue << param
      'Parameter2' => insteonID[1],
+
SndIns()
      'Parameter3' => insteonID[2],
+
 
      'Parameter4' => '0F',  
+
end
      'Parameter5' => '11',
+
end
      'Parameter6' => dim_level}
+
 
    $cmdqueue << param
+
when 279 #Fan Control
    SndIns()
+
log('Processing Fan Control command')
  else
+
log($cmdParams)
 +
if insteonID.length > 2 then
 +
 
 +
case $cmdParams.to_s
 +
when '81' # Fan ON
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B',
 +
'Parameter6' => '07'} # Sets Fan to ON
 +
log(param)
 +
when '82' # Fan OFF
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B',
 +
'Parameter6' => '08'} # Sets fan OFF
 +
$cmdqueue << param
 +
SndIns()
 +
end
 +
end
 +
 
 +
when 280 # Heat/Cool/Auto
 +
log('Processing Heat/Cool/Auto command')
 +
#log('Test Param:' +$cmdParams.to_s)
 +
if insteonID.length > 2 then
 +
case $cmdParams.to_s
 +
when '8H' # Heat Command
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B', # Indicates device is a Thermostat
 +
'Parameter6' => '04'} # sets to Heat Mode
 +
$cmdqueue << param
 +
SndIns()
 +
 
 +
when '8C' # Cool Command
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B',
 +
'Parameter6' => '05'} # Sets to Cool
 +
$cmdqueue << param
 +
SndIns()
 +
 
 +
when '8A' # Auto Command
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B',
 +
'Parameter6' => '06'} # Sets to Auto
 +
 
 +
$cmdqueue << param
 +
SndIns()
 +
end
 +
end
 +
when 192 # ON
 +
log('Processing ON command')
 +
if insteonID.length > 2 then
 +
if childType == 2198 then #Used For Thermostat only Sets to Auto, No on command.
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B', # Indicates device is a Thermostat
 +
'Parameter6' => '06'} # sets to Auto
 +
else #Used For Everything else
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '11',
 +
'Parameter6' => 'FF'}
 +
end
 +
$cmdqueue << param
 +
SndIns()
 +
else
 +
log "------dce--- X10 DEVICE!!!"
 +
# Send X10 ON command.
 +
#first, figure out the house code and unit code.
 +
log('DeviceID=' + deviceID)
 +
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
 +
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
 +
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
 +
x10cmd += '2' # command code for ON
 +
log('X10 Byte1:' + x10Byte1)
 +
param = {'Command' => 'SndX10',
 +
'Parameter1' => x10Byte1,
 +
'Parameter2' => '00'}
 +
$cmdqueue << param
 +
param = {'Command' => 'SndX10',
 +
'Parameter1' => x10cmd,
 +
'Parameter2' => '80'}
 +
$cmdqueue << param
 +
SndIns()
 +
end
 +
reportStatus($children[deviceID], 100)
 +
when 193 #OFF
 +
if insteonID.length > 2 then
 +
if childType == 2198 then #Used For Thermostat only
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '6B', # Indicates Device is Thermostat
 +
'Parameter6' => '09'} # Sets to Off
 +
else
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '13',
 +
'Parameter6' => '00'}
 +
end
 +
$cmdqueue << param
 +
SndIns()
 +
else
 +
log "------dce--- X10 DEVICE!!!"
 +
log('DeviceID=' + deviceID)
 +
 
 +
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
 +
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
 +
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
 +
x10cmd += '3' # command code for OFF
 +
log('X10 Byte1:' + x10Byte1)
 +
param = {'Command' => 'SndX10',
 +
'Parameter1' => x10Byte1,
 +
'Parameter2' => '00'}
 +
$cmdqueue << param
 +
param = {'Command' => 'SndX10',
 +
'Parameter1' => x10cmd,
 +
'Parameter2' => '80'}
 +
$cmdqueue << param
 +
SndIns()
 +
 
 +
end
 +
reportStatus($children[deviceID], 0)
 +
when 193
 +
if insteonID.length > 2 then
 +
#Needs Work
 +
 
 +
end
 +
 
 +
when 184 #SetLevel
 +
# convert from percent to hex
 +
dim_level = percenttohex(cmd.params_[76])
 +
#log("------dce--- Dim Level:" + dim_level.to_s)
 +
if insteonID.length > 2 then
 +
 
 +
param = {'Command' => 'SndIns',
 +
'Parameter1' => insteonID[0],
 +
'Parameter2' => insteonID[1],
 +
'Parameter3' => insteonID[2],
 +
'Parameter4' => '0F',
 +
'Parameter5' => '11',
 +
'Parameter6' => dim_level}
 +
$cmdqueue << param
 +
SndIns()
 +
else
 
# In the PRESET DIM X10 command, the lsbit of the command code is the MSB of the
 
# In the PRESET DIM X10 command, the lsbit of the command code is the MSB of the
 
# dim level, and the house code represents the 4 lsbits of the dim level.
 
# dim level, and the house code represents the 4 lsbits of the dim level.
 
# This is why Pre-Set Dim command is A AND B.
 
# This is why Pre-Set Dim command is A AND B.
log('Parameter 76 = ' + cmd.params_[76].to_s)
+
log('Parameter 76 = ' + cmd.params_[76].to_s)
    log "X10 DEVICE!!! relative Dimming command"
+
log "X10 DEVICE!!! relative Dimming command"
    log('DeviceID=' + deviceID)
+
log('DeviceID=' + deviceID)
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
+
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
+
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
+
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
    #first, determine if its UP or Down
+
#first, determine if its UP or Down
  
if $state[deviceID].to_i > hextopercent(dim_level).to_i
+
if $state[deviceID].to_i > hextopercent(dim_level).to_i
# DOWN
+
# DOWN
x10cmd += $X10CommandCodes.index('Dim')
+
x10cmd += $X10CommandCodes.index('Dim')
else
+
else
# UP
+
# UP
x10cmd += $X10CommandCodes.index('Bright')
+
x10cmd += $X10CommandCodes.index('Bright')
end
+
end
  
log('X10 Byte1:' + x10Byte1)
+
log('X10 Byte1:' + x10Byte1)
param = {'Command' => 'SndX10',  
+
param = {'Command' => 'SndX10',
        'Parameter1' => x10Byte1,
+
'Parameter1' => x10Byte1,
        'Parameter2' => '00'}
+
'Parameter2' => '00'}
$cmdqueue << param
+
$cmdqueue << param
param = {'Command' => 'SndX10',
+
param = {'Command' => 'SndX10',
'Parameter1' => x10cmd,
+
'Parameter1' => x10cmd,
'Parameter2' => '80'}
+
'Parameter2' => '80'}
$cmdqueue << param
+
$cmdqueue << param
  
    SndIns()
+
SndIns()
    log('Dim Level:' + hextopercent(dim_level).to_s)
+
log('Dim Level:' + hextopercent(dim_level).to_s)
    #now send status info (we should not have to to this, but do)
+
#now send status info (we should not have to to this, but do)
    reportStatus($children[deviceID], hextopercent(dim_level))
+
reportStatus($children[deviceID], hextopercent(dim_level))
  end
+
end
 +
 
 +
end
  
end</pre>
+
</pre>

Latest revision as of 10:30, 3 July 2016

Version Status Date Updated Updated By
710 Unknown N/A N/A
810 Unknown N/A N/A
1004 Unknown N/A N/A
1204 Unknown N/A N/A
1404 Unknown N/A N/A
Usage Information
#### Written by Dan Damron
#### #384 Process Receive Command for Child ####
#
#Commands needing implementation
# Climate Events:
# 25 Temperature Changed  Partially working
# 26 Humidity Changed     Partially working
# 27 Thermostat Set Point Changed  Partially working

# Security Commands:
# 746 Disarm Panel
# 758 Get Sensors List
# 19 Set House Mode
# 387 Verify PIN
# Security Events:
# 9 Sensor Tripped
# 16 Security Breach
# 17 Fire Alarm
# 18 Reset Alarm
# 39 Air Quality
# 40 Doorbell
# 41 Monitor Mode
# 42 Movement Detected
# 43 House Mode Changed
# 44 Presence Detected
# 45 Presence Lost
# 67 Alarm Panel Mode Change






deviceID = device_.childdevices_[cmd.devidto_].devdata_[12]
insteonID = deviceID.chomp.split('.')
$cmdID = cmd.id_
$cmdTo = cmd.devidto_
childType = device_.childdevices_[cmd.devidto_].devtemplid_
$cmdFrom = cmd.devidfrom_
$cmdPriority = cmd.priority_
$cmdType = cmd.type_
$cmdParams = cmd.params_
##Used Only for Thermostat Tempruature Changes########
$TempParamSplit =cmd.params_.to_s.split('/') # splits Tempurature string to allow for heat and cool settings
$ConvertTempInt = $TempParamSplit[1].to_i * 2
$ConvertTempHex = $ConvertTempInt.to_s(16) #Converts temp to hex to send to Thermostat
#################################
log('------dce--- cmdID:' + $cmdID.to_s + ', cmdFrom:' + $cmdFrom.to_s + ', cmdTo:' + $cmdTo.to_s + ', cmdType:' + $cmdType.to_s + ', Priority:' + $cmdPriority.to_s)
if $cmdTo == $cmdFrom
log('Detected Command sent to Self!')
return
end
case cmd.id_

when 278 # Set Temp
log('Processing Temp Control command')
#log($cmdParams)
if insteonID.length > 2 then
case $TempParamSplit[0].to_s
when '5C' #sending Heatpoint Tempurature
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6C', # Defines Cool Setpoint
'Parameter6' => $ConvertTempHex} # send Tempurature Value in Hex
$cmdqueue << param
SndIns()

when '5H' #sending Heatpoint Tempurature
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6D', # Defines Heat Setpoint
'Parameter6' => $ConvertTempHex} # send Tempurature Value in Hex
$cmdqueue << param
SndIns()

end
end

when 279 #Fan Control
log('Processing Fan Control command')
log($cmdParams)
if insteonID.length > 2 then

case $cmdParams.to_s
when '81' # Fan ON
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B',
'Parameter6' => '07'} # Sets Fan to ON
log(param)
when '82' # Fan OFF
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B',
'Parameter6' => '08'} # Sets fan OFF
$cmdqueue << param
SndIns()
end
end

when 280 # Heat/Cool/Auto
log('Processing Heat/Cool/Auto command')
#log('Test Param:' +$cmdParams.to_s)
if insteonID.length > 2 then
case $cmdParams.to_s
when '8H' # Heat Command
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B', # Indicates device is a Thermostat
'Parameter6' => '04'} # sets to Heat Mode
$cmdqueue << param
SndIns()

when '8C' # Cool Command
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B',
'Parameter6' => '05'} # Sets to Cool
$cmdqueue << param
SndIns()

when '8A' # Auto Command
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B',
'Parameter6' => '06'} # Sets to Auto

$cmdqueue << param
SndIns()
end
end
when 192 # ON
log('Processing ON command')
if insteonID.length > 2 then
if childType == 2198 then #Used For Thermostat only Sets to Auto, No on command.
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B', # Indicates device is a Thermostat
'Parameter6' => '06'} # sets to Auto
else #Used For Everything else
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '11',
'Parameter6' => 'FF'}
end
$cmdqueue << param
SndIns()
else
log "------dce--- X10 DEVICE!!!"
# Send X10 ON command.
#first, figure out the house code and unit code.
log('DeviceID=' + deviceID)
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
x10cmd += '2' # command code for ON
log('X10 Byte1:' + x10Byte1)
param = {'Command' => 'SndX10',
'Parameter1' => x10Byte1,
'Parameter2' => '00'}
$cmdqueue << param
param = {'Command' => 'SndX10',
'Parameter1' => x10cmd,
'Parameter2' => '80'}
$cmdqueue << param
SndIns()
end
reportStatus($children[deviceID], 100)
when 193 #OFF
if insteonID.length > 2 then
if childType == 2198 then #Used For Thermostat only
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '6B', # Indicates Device is Thermostat
'Parameter6' => '09'} # Sets to Off
else
param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '13',
'Parameter6' => '00'}
end
$cmdqueue << param
SndIns()
else
log "------dce--- X10 DEVICE!!!"
log('DeviceID=' + deviceID)

x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
x10cmd += '3' # command code for OFF
log('X10 Byte1:' + x10Byte1)
param = {'Command' => 'SndX10',
'Parameter1' => x10Byte1,
'Parameter2' => '00'}
$cmdqueue << param
param = {'Command' => 'SndX10',
'Parameter1' => x10cmd,
'Parameter2' => '80'}
$cmdqueue << param
SndIns()

end
reportStatus($children[deviceID], 0)
when 193
if insteonID.length > 2 then
#Needs Work

end

when 184 #SetLevel
# convert from percent to hex
dim_level = percenttohex(cmd.params_[76])
#log("------dce--- Dim Level:" + dim_level.to_s)
if insteonID.length > 2 then

param = {'Command' => 'SndIns',
'Parameter1' => insteonID[0],
'Parameter2' => insteonID[1],
'Parameter3' => insteonID[2],
'Parameter4' => '0F',
'Parameter5' => '11',
'Parameter6' => dim_level}
$cmdqueue << param
SndIns()
else
# In the PRESET DIM X10 command, the lsbit of the command code is the MSB of the
# dim level, and the house code represents the 4 lsbits of the dim level.
# This is why Pre-Set Dim command is A AND B.
log('Parameter 76 = ' + cmd.params_[76].to_s)
log "X10 DEVICE!!! relative Dimming command"
log('DeviceID=' + deviceID)
x10Byte1 = $X10HouseCodes.index(deviceID[0].chr)
x10Byte1 += $X10UnitCodes.index(deviceID[1].chr)
x10cmd = $X10HouseCodes.index(deviceID[0].chr)
#first, determine if its UP or Down

if $state[deviceID].to_i > hextopercent(dim_level).to_i
# DOWN
x10cmd += $X10CommandCodes.index('Dim')
else
# UP
x10cmd += $X10CommandCodes.index('Bright')
end

log('X10 Byte1:' + x10Byte1)
param = {'Command' => 'SndX10',
'Parameter1' => x10Byte1,
'Parameter2' => '00'}
$cmdqueue << param
param = {'Command' => 'SndX10',
'Parameter1' => x10cmd,
'Parameter2' => '80'}
$cmdqueue << param

SndIns()
log('Dim Level:' + hextopercent(dim_level).to_s)
#now send status info (we should not have to to this, but do)
reportStatus($children[deviceID], hextopercent(dim_level))
end

end