Author Topic: Insteon PLM code for PeteK  (Read 5280 times)

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Insteon PLM code for PeteK
« on: December 22, 2007, 10:26:46 pm »
I have to split it up..
All these routines go into internal ruby commands...

Code: [Select]
#### Written by Dan Damron
#### #373 Private Method Listing ####

def setdeviceconfig(insteonid, configurestring)
@deviceid = $children[insteonid]
@cmdfrom = device_.devid_
@cmdto = 4 #general info plugin
@priority = 1
@type=1 #command
@cmdid = 246

#set up command..
@cmd = Command.new(@cmdfrom, @cmdto, @priority, @type, @cmdid)
@cmd.params_[2] = @deviceid.to_s
@cmd.params_[52] = '59' # Configuration
@cmd.params_[5] = configurestring
SendCommand(@cmd)
log('Configuration Saved - will be available on next reload')
end

def getdeviceconfig(insteonid)
@deviceid = $children[insteonid]
begin
@configstring = device_.childdevices_[@deviceid].devdata_[59].to_s
rescue
log('Device ID = ' + @deviceid.to_s)
log($red + 'Error - Child has no configuration'+ $grey)
log('Setting initial value of ""')
setdeviceconfig(insteonid, ('0' * 16))
@configstring = '0' * 16
end
if @configstring == ''
@configparams = []
else
$configparams = @configstring.unpack('a16' * (@configstring.length / 16))
end
#add the configuration parameters to the child database
$childdatabases[insteonid] = $configparams

# time to define a structure to save the raw data
# Byte Meaning
# 1 Device Category
# 2 Device SubCategory
# 3 Device Firmware
# 4 Database Delta
# 5 reserved
# 6 reserved
# 7 reserved
# 8 reserved
###### First database record below (in same format its read from the device)
###### This is the same format as an ALL-Link Record Response from the PLM
###### (0x57) bytes 3..10
# 9 record control byte
# 10 Group
# 11 ID HB
# 12 ID MB
# 13 ID LB
# 14 Link Specific Data1
# 15 Link Specific Data2
# 16 Link Specific Data3
######
# 17-24 next database record...
end

def getLnk()
#lets just see exactly what is in the PLM database
param = {'Command' => 'GetLnk'}
$cmdqueue << param
SndIns()
end

def getNext()
param = {'Command' => 'GetNext'}
$cmdqueue << param
SndIns()
end


def remoteGetLnk(insteonID)
# Read First ALDB Record
# a few variables need to be set up here..
$recordof = insteonID # save the insteon ID
insID = insteonID.chomp.split('.') # get the seperate bytes
$remoteDBOffsetMSB = 0x0F # initial offset
$remoteDBOffsetLSB = 0xF8 # initial LSB offset
param = {'Command' => 'SndIns',
'Parameter1' => insID[0], #HB
'Parameter2' => insID[1], #MB
'Parameter3' => insID[2], #LB
'Parameter4' => '0F', #Flags
'Parameter5' => '28', #Cmd1
'Parameter6' => "%X" %$remoteDBOffsetMSB #Cmd2 Set MSB Offset
}
$cmdqueue << param
# repeat last param for each byte to read (F8..FF)=first record

for x in 0..7
param = {'Command' => 'SndIns',
'Parameter1' => insID[0], #HB
'Parameter2' => insID[1], #MB
'Parameter3' => insID[2], #LB
'Parameter4' => '0F', #Flags
'Parameter5' => '2B', #Cmd1 Peek
'Parameter6' => "%X" %($remoteDBOffsetLSB + x) #Cmd2
}

$cmdqueue << param
end

end

def remoteGetNext(insteonID)
insID = insteonID.chomp.split('.') # get the seperate bytes
### Do NOT forget to check to see if we need to decrease the MSB

if $remoteDBOffsetLSB == 0x00
#OffsetMSB needs to be decreased, and LSB needs reset.
$remoteDBOffsetMSB = $remoteDBOffsetMSB - 1
$remoteDBOffsetLSN = 0xFF # the next line will decrease this by 8
end
# decrease DBOffsetLSB by 0x08
$remoteDBOffsetLSB = $remoteDBOffsetLSB - 0x08

for x in 0..7
param = {'Command' => 'SndIns',
'Parameter1' => insID[0], #HB
'Parameter2' => insID[1], #MB
'Parameter3' => insID[2], #LB
'Parameter4' => '0F', #Flags
'Parameter5' => '2B', #Cmd1 Peek
'Parameter6' => "%X" %($remoteDBOffsetLSB + x) #Cmd2
}

$cmdqueue << param
end
end


def EZToDCE(param)
#param contains a hash of EZBridge command structure
#log($blue + 'Queue:' + $cmdqueue[0].inspect + $grey)
#log($blue + 'Param:' + param.inspect + $grey)
checkWait(param)
case param['Response']
# Standard RESPONSES (to commands)
when 'GetRevision' # Special Response
log('-----|---------GetRevision:' + param['Parameter1'])

when 'GetLatLong'  # Special Response
log('-----|---------GetLatLong: Lat=' + param['Lat'] + ', Long=' + param['Long'])

when 'SetLatLong'
if param['Parameter1'] = 'True' then
log('-----|---------SetLatLong: Ok')
else
log('-----X---------SetLatLong: FAILED!')
end
when 'SetPasswd'

when 'SetTimeZone'

when 'GetClock' # Special Response

when 'SetClock'

when 'SetNTPServer'

when 'Upgrade'

when 'NetCfg'

when 'Reset'
#Reset Response
cmdComplete
when 'LstTimers'  # Special Response


when 'ClrTimers'

when 'AddTimer'

when 'GetTimer'    # Special Response

when 'SetTimer'

when 'DelTimer'

when 'GetVersion' # Special Response

when 'SndGrp'

when 'SndIns' # response from SndIns
### BUG FOUND ### When the EZBridge receives a command from an EXTERNAL source
### ie not from this device, cmdqueue will be nil, and the code below
### fails.  Have to check against that.
   if $cmdqueue.length > 0
#First, check the response to make sure the command made it ok.
if param['Parameter9'].to_i == 6 #Ack received
case param['Parameter7'].hex #Received an ack to THIS command
when 0x1 #Assign to Group
log('Got Assign to Group ACK')
$currentcmd = 0x01
$cmdqueue[0]['Command'] = 'InsStdMsg'
#getDeviceInfo(param)
#cmdComplete
when 0x2 #Delete from Group
when 0x10 # PING
log('Got PING ACK')
$currentcmd = 0x10
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x11 #ON
$currentcmd = 0x11
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x13 #OFF
$currentcmd = 0x13
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x15 #Bright
$currentcmd = 0x15
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x16 #DIM
$currentcmd = 0x16
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x17 #Start Manual Change
when 0x18 #Stop Manual Change
when 0x19 #Status Request
# Status Request Acked - get ready for InsStdMsg
$currentcmd = 0x19
# change cmd to reflect InsStdMsg
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x24
log('Caught ACK for Insteon DO EE READ')
$currentcmd = 0x24
$cmdqueue[0]['Command'] = 'InsStdMsg'
when 0x28
#log('Caught ACK for Insteon SET ADDRESS MSB')
$currentcmd = 0x28
$cmdqueue[0]['Command'] = 'InsStdMsg'

when 0x29
log('Caught ACK for Insteon POKE')
$currentcmd = 0x29
$cmdqueue[0]['Command'] = 'InsStdMsg'

when 0x2A
log('Caught ACK for Insteon POKE EXTENDED')
$currentcmd = 0x2A
$cmdqueue[0]['Command'] = 'InsStdMsg'

when 0x2B
#log('Caught ACK for Insteon PEEK')
$currentcmd = 0x2B
$cmdqueue[0]['Command'] = 'InsStdMsg'

when 0x2C
log('Caught ACK for Insteon PEEK INTERNAL')
$currentcmd = 0x2C
$cmdqueue[0]['Command'] = 'InsStdMsg'

when 0x2D
log('Caught ACK for Insteon POKE INTERNAL')
$currentcmd = 0x2D
$cmdqueue[0]['Command'] = 'InsStdMsg'

else
log('Unknown Insteon Cmd1')
end

else # NACK received - command failed.
log('Command NACKED')
end
   else
#Response received for another device.
log('Response detected for a command that was not sent by me')
   end
when 'SndX10'

when 'StLnk'

when 'CancelLnk'

when 'SetDev'

when 'RstPLM'

when 'GetLnk'
if param['Parameter3'].to_i == 6 #ack
log('GetLnk ACKED')
#if we get this, we should get a AllLink Record Response next
else
log('GetLnk NACKED')
# we should NEVER get this as there should always be
# at least ONE record in the PLM
cmdComplete
end
when 'GetNext'
if param['Parameter3'].to_i == 6 #ack
log('GetNext ACKED')
#if we get this, we should get a AllLink Record Response next
else
log('GetNext NACKED')
#we get this when there are no more records
cmdComplete
# if we are here, we are in config mode
# so, next is to check to make sure the
# childrens insteon ID is in the PLM
checkChildRecordsinPLM()
end

when 'SetCfg' # response from Setcfg command
if param['Parameter4'].to_i == 6 #ack
log('SetCfg Completed')
cmdComplete
else
log('SetCfg NACKED')
end
when 'GetLnkData'

when 'LEDON'

when 'LEDOFF'

when 'MngLnk'
if param['Parameter12'].to_i == 6
log('MngLnk => ACK')
else
log('MngLnk => NACK')
end
cmdComplete

when 'GetCfg' # Special Response

when 'LstMacros' # Special Response

when 'ClrMacros'

when 'AddMacro'

when 'GetMacro' # Special Response

when 'SetMacro'

when 'DelMacro'

when 'LstDevices' # Special Response

when 'ClrDevices'

when 'AddDevice'

when 'GetDevice' # Special Response

when 'SetDevice'

when 'DelDevice'

when 'LstZones'

when 'ClrZones'

when 'AddZone'

when 'GetZone'

when 'SetZone'

when 'DelZone'

when 'AddDevZone'

when 'DelDevZone'

# Response Messages
when 'InsExtMsg'

when 'InsStdMsg'
case $currentcmd # if this msg is part of a response, the Insteon Cmd1 will be saved here.
when 0x0
#there is no current command
# THIS IS COMING FROM AN OUTSIDE SOURCE
#EG: Manually turning Light Switch On/Off
# process this command.
# Note, this is a standard message
### have to check here if child is mine!

# there is no ack here.  Simply Send EVENTS back to DCE
# and Complete the recv..
case param['Parameter10'].hex #this is the command
when 0x01 #Assign to Group
log('Caught EXTERNAL Assign to Group')
getDeviceInfo(param)
recvComplete
when 0x02 #Delete from Group
log('Caught EXTERNAL Delete from Group')
recvComplete
when 0x10 # PING
log('Caught EXTERNAL Insteon PING result')
recvComplete


when 0x11 #ON
log('Caught EXTERNAL Insteon ON command result')
#on level is in cmd2
insHb = param['Parameter3'] # From
insMb = param['Parameter4']
insLb = param['Parameter5']
insID = insHb + "." + insMb + "." + insLb
log('From:' +insID)
log('Device:' + $children[insID].to_s)
myDevFrom = $children[insID]
# check to see if I own child
if myDevFrom == nil
log('I do not control this device.')
else
myDevTo = -1000 #DCE Router
myPriority = 1
myType = 2 #Event
#Send an EVENT
#Event #48, pipe 10, value 1=on, 2=off
cmd = Command.new(myDevFrom, myDevTo, myPriority, myType, 48) #Event
cmd.params_[10] = '1' # EVENT ON
SendCommand(cmd)
$currentcmd = 0
log('EVENT SENT!!!.48:[10]=1')
end
recvComplete



when 0x13 #OFF
log('Caught EXTERNAL Insteon OFF result')
#on level is in cmd2
insHb = param['Parameter3'] # From
insMb = param['Parameter4']
insLb = param['Parameter5']
insID = insHb + "." + insMb + "." + insLb
myDevFrom = $children[insID]
if myDevFrom == nil
log('I do not control this device.')
else

myDevTo = -1000 #DCE Router
myPriority = 1
myType = 2 #Event
#Send an EVENT
#Event #48, pipe 10, value 1=on, 2=off
cmd = Command.new(myDevFrom, myDevTo, myPriority, myType, 48) #Event
cmd.params_[10] = '0' # EVENT OFF
SendCommand(cmd)
$currentcmd = 0
log('EVENT SENT!!!.48:[10]=0')
end
recvComplete



when 0x15; log('Caught EXTERNAL Insteon Brighten Result')
when 0x16; log('Caught EXTERNAL Insteon DIM Result')
when 0x24; log('Caught EXTERNAL Insteon DO EE READ')
when 0x28; log('Caught EXTERNAL Insteon SET ADDRESS MSB')
when 0x29; log('Caught EXTERNAL Insteon POKE')
when 0x2A; log('Caught EXTERNAL Insteon POKE EXTENDED')
when 0x2B; log('Caught EXTERNAL Insteon PEEK')
when 0x2C; log('Caught EXTERNAL Insteon PEEK INTERNAL')
when 0x2D; log('Caught EXTERNAL Insteon POKE INTERNAL')
else
log('Unknown EXTERNAL Insteon Command.')
end
when 0x1 #Assign to Group
### This is a broadcast message sent
# from a PING command
# or from a StartLink...
log('Caught Assign to Group Message from Device')
getDeviceInfo(param)
$currentcmd = 0
cmdComplete
when 0x2 #Delete from Group
when 0x10 # PING
#this is where I catch the InsStdMsg for ping.
log('Caught PING Message from Device')
$currentcmd = 1

when 0x11 # ON
log('Caught Insteon ON from INTERNAL source')
insHb = param['Parameter3'] # From
insMb = param['Parameter4']
insLb = param['Parameter5']
insID = insHb + "." + insMb + "." + insLb
myDevFrom = $children[insID]
myDevTo = -1000 #DCE Router
myPriority = 1
myType = 2 #Event
#Send an EVENT
#Event #48, pipe 10, value 1=on, 2=off
cmd = Command.new(myDevFrom, myDevTo, myPriority, myType, 48) #Event
cmd.params_[10] = '1' # EVENT ON
SendCommand(cmd)
$currentcmd = 0
cmdComplete
log('EVENT SENT!!!.48:[10]=1')
when 0x13 # OFF
insHb = param['Parameter3'] # From
insMb = param['Parameter4']
insLb = param['Parameter5']
insID = insHb + "." + insMb + "." + insLb
myDevFrom = $children[insID]
myDevTo = -1000 #DCE Router
myPriority = 1
myType = 2 #Event
#Send an EVENT
#Event #48, pipe 10, value 1=on, 2=off
cmd = Command.new(myDevFrom, myDevTo, myPriority, myType, 48) #Event
cmd.params_[10] = '0' # EVENT OFF
SendCommand(cmd)
$currentcmd = 0
cmdComplete
log('EVENT SENT!!!.48:[10]=0')
when 0x19 # Status Report
#This is where I get the database delta (in cmd1)
insHb = param['Parameter3'] # From
insMb = param['Parameter4']
insLb = param['Parameter5']
insID = insHb + "." + insMb + "." + insLb
myDevFrom = $children[insID]
myDevTo = -1000 #DCE Router
myPriority = 1
myType = 2 #Event
#Send an EVENT
#Event #48, pipe 10, value 1=on, 2=off
cmd = Command.new(myDevFrom, myDevTo, myPriority, myType, 48) #Event
#cant send dim value, only on or off
#cmd.params_[184] = hextopercent(param['Parameter8']).to_s
#Database Delta...
delta = param['Parameter7'].to_s
log($redBack + 'Database Delta=' + delta + $blackBack)
if param['Parameter11'].hex.to_i == 0 #if off
cmd.params_[10] = '0' # Send Event OFF
else
cmd.params_[10] = '1' # otherwise, send EVENT ON
end
#log('Parameter11 = ' + param['Parameter11'].to_s)
#log('Params_[10] = ' + cmd.params_[10].to_s)
SendCommand(cmd)
log('Initial Status EVENT SENT!!!..............')
# now to clear the currentcmd and remove command from the queue
$currentcmd = 0
cmdComplete
when 0x28 # Set Address MSB
#log('Received SET Address MSB from remote device')
$currentcmd = 0
cmdComplete
when 0x2B # peek
#log('Received PEEK from remote Device! DATA=' + param['Parameter11'])
getPeekData(param)
$currentcmd = 0
cmdComplete
else
end

when 'X10Msg'
log('X10 Message Received')

when 'InsLnkSts'
log('InsLnkSts Received')

when 'BtnRpt'
log('Button Report Received')
when 'UsrRst'
log('User Reset Response Received')
when 'GrpEvntRpt'
log('Group Event Report Received')

when 'LnkData'
#Caught a LnkData Response
log('LnkData Message Received')
insteonID = param['Parameter5'] + '.' + param['Parameter6'] + '.' + param['Parameter7']
group = param['Parameter4']
recflags = param['Parameter3']
lnkdata1 = param['Parameter8']
lnkdata2 = param['Parameter9']
lnkdata3 = param['Parameter10']
#pack string to store for PLM Database
@currentrecord = recflags + group
@currentrecord += param['Parameter5'] + param['Parameter6'] + param['Parameter7']
@currentrecord += lnkdata1 + lnkdata2 + lnkdata3

#Add to plmdatabase
$plmdatabase << @currentrecord
log('PLM database=' +$plmdatabase.inspect)
if (recflags[0] & 0x80) == 0x80 # Record is in use if true
end
if (recflags[0] & 0x40) == 0x40 # Controller if true
log('Controller')
else
log('Responder')
end

log('Insteon ID:' + insteonID + ', Group:' + group)

cmdComplete
getNext() # get next database record...
# Other messages
when 'PLMTimeout'
log('PLM Timeout detected.. resetting EZBridge')
resetcmd = {'Command' => 'Reset'}
$cmdqueue.insert(0, resetcmd)
sleep 15
$wAIT = false
SndIns()
when 'PLMEchoError' # Have not seen this since a1.23
# error sending command to PLM, reset command and try again
log('-----XXXXXXX' + param['Response'])
resetcmd = {'Command' => 'Reset'}
$cmdqueue.insert(0, resetcmd)
sleep 15
$wAIT = false
SndIns()
when 'LongAck'
log('-----XXXXXXX' + param['Response'])
# Error - seems to show up after PLMEchoError
resetcmd = {'Command' => 'Reset'}
$cmdqueue.insert(0, resetcmd)
sleep 15
$wAIT = false
SndIns()
else
log('-----XXXXXXX UNKNOWN Response Received:' + param['Response'])
end

end

« Last Edit: December 22, 2007, 11:46:41 pm by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Insteon PLM code for PeteK
« Reply #1 on: December 22, 2007, 10:28:30 pm »
373 Private Listing continued

Code: [Select]
def getPeekData(param)

$remoteLinkRecord += param['Parameter11'].hex.chr
if $remoteLinkRecord.length == 8
log('REMOTE RECORD COMPLETE!')
processRemoteRecord
$remoteLinkRecord = ''
end

# below did not work - position cannot be trusted...
#########################################################################
# position = param['Parameter10'].hex.modulo(8) #get bytes position
# $remoteLinkRecord[position] = param['Parameter11'].hex
# $remoteRecordReady += 2**position # set bit
# log('Position=' + position.to_s)
# log('remoteRecordReady=' + $remoteRecordReady.to_s)
# if $remoteRecordReady == 0xFF # all 8 bytes populated
# log('REMOTE RECORD COMPLETE!')
# processRemoteRecord
# $remoteRecordReady = 0
# $remoteLinkRecord = '        '
#
# end
end


def processRemoteRecord()
log('Processing remote Record below:')
@flags = "\nFrom Device:" + $recordof + "\nFlags:\n"

if ($remoteLinkRecord[0] & 0x02) == 0x02 # High water mark
@flags += "Not the last record\n"
else
@flags += "This IS the last record\n"
end

if ($remoteLinkRecord[0] & 0x80) == 0x80 # Record is in use
@flags += "Record In Use\n"
if ($remoteLinkRecord[0] & 0x40) == 0x40 # Controller/Responder
@flags += "I am a Controller of "
else
@flags += "I am a Responder of "
end
@insteonID = "%X" %$remoteLinkRecord[2] + '.'
@insteonID += "%X" %$remoteLinkRecord[3] + '.'
@insteonID += "%X" %$remoteLinkRecord[4]
@group = "%X" %$remoteLinkRecord[1]
@flags += @insteonID + " Group:" + @group
else
@flags += "Record NOT in use\n"
end
log($aqua + @flags + $grey)
end

def getDeviceInfo(param)
### temporary
log($yellow)
case param['Parameter6'].hex
  when 0x0 # Generalized Controllers
case param['Parameter7'].hex
when 0x04; log('Found ControLinc [2430]')
when 0x05; log('Found RemoteLinc [2440]')
when 0x06; log('Found Icon Tabletop Controller [2830]')
when 0x09; log('Found SignaLinc RF Signal Enhancer [2442]')
when 0x0A; log('Found Balboa Instruments Poolux LCD Controller')
when 0x0B; log('Found Access Point [2443]')
when 0x0C; log('Found IES Color Touchscreen')
end
  when 0x01 # Dimmable Lighting Control
case param['Parameter7'].hex
when 0x00; log('Found LampLinc V2 [2456D3]')
when 0x01; log('Found SwitchLinc V2 Dimmer 600W [2476D]')
when 0x02; log('Found In-LineLinc Dimmer [2475D]')
when 0x03; log('Found Icon Switch Dimmer [2876D]')
when 0x04; log('Found SwitchLinc V2 Dimmer 1000W [2476DH]')
when 0x06; log('Found LampLinc 2-pin [2456D2]')
when 0x07; log('Found Icon LampLinc V2 2-pin [2456D2]')
when 0x09; log('Found KeypadLinc Dimmer [2486D]')
when 0x0A; log('Found Icon In-Wall Controller [2886D]')
when 0x0D; log('Found SocketLinc [2454D]')
when 0x13; log('Found Icon SwitchLinc Dimmer for Lixar/Bell Canada [2676D-B]')
when 0x17; log('Found ToggleLinc Dimmer [2466D]')
end
  when 0x02 # Switched Lighting Control
case param['Parameter7'].hex
when 0x09; log('Found ApplianceLinc [2456S3]')
when 0x0A; log('Found SwitchLinc Relay [2476S]')
when 0x0B; log('Found Icon On Off Switch [2876S]')
when 0x0C; log('Found Icon Appliance Adapter [2856S3]')
when 0x0D; log('Found ToggleLinc Relay [2466S]')
when 0x0E; log('Found Switchlinc Relay Countdown Timer [2476ST]')
when 0x10; log('Found In-LineLinc Relay [2475D]')
when 0x13; log('Found Icon SwitchLinc Relay for Lixar/Bell Canada [2676R-B]')
end
  when 0x03 # Network Bridges
case param['Parameter7'].hex
when 0x01; log('Found PowerLinc Serial [2414S]')
when 0x02; log('Found PowerLinc USB [2414U]')
when 0x03; log('Found Icon PowerLinc Serial [2814S]')
when 0x04; log('Found Icon PowerLinc USB [2814U]')
when 0x05; log('Found Smartlabs Power Line Modem Serial [2412S]')
end
  when 0x04 # Irrigation Control
case param['Parameter7'].hex
when 0x00; log('Found Simplehomenet EZRain1 Sprinkler Controller')
end
  when 0x05 # Climate Control
case param['Parameter7'].hex
when 0x00; log('Found Broan SMSC080 Exhaust Fan')
when 0x01; log('Found Simplehomenet EZTherm')
when 0x02; log('Found Broan SMSC110 Exhaust Fan')
when 0x03; log('Found Venstar RF Thermostat Module')
when 0x04; log('Found Simplehomenet EZStat Thermostat')
end
  when 0x06 # Pool and Spa Control
case param['Parameter7'].hex
when 0x00; log('Found Simplehomenet EZPool')
end
  when 0x07 # Sensors and Actuators
case param['Parameter7'].hex
when 0x00
end
  when 0x08 # Home Entertainment
case param['Parameter7'].hex
when 0x00
end
  when 0x09 # Energy Management
case param['Parameter7'].hex
when 0x00
end
  when 0x0A # Built-In Appliance Control
case param['Parameter7'].hex
when 0x00
end
  when 0x0B # Plumbing
case param['Parameter7'].hex
when 0x00
end
  when 0x0C # Communication
case param['Parameter7'].hex
when 0x00
end
  when 0x0D # Computer Control
case param['Parameter7'].hex
when 0x00
end
  when 0x0E # Window Coverings
case param['Parameter7'].hex
when 0x00
end
  when 0x0F # Access Control
case param['Parameter7'].hex
when 0x00
end
  when 0x10 # Security, Health, and Safety
  when 0x11 # Surveillance
  when 0x12 # Automotive
  when 0x13 # Pet care
  when 0x14 # Toys
  when 0x15 # Timekeeping
  when 0x16 # Holiday
end
### eventually, open a XML configuration script?
### or read saved data from mysql?
### most likely save this information to sql with device.
### eventually, IPKDB will be available to ping.

log($grey)
end

def recvComplete
# Clears the wait flag, but does not remove a command from the queue
$wAIT = false
log ($green + "Receive Completed.  Checking command queue" + $grey)
if $cmdqueue.nitems > 0 then
log("Queue:" + $aqua + $cmdqueue.nitems.to_s + $grey + " : executing next command")
SndIns()
else
log($yellow + 'Queue Empty.' + $grey)
end
end
def cmdComplete
# Clears the wait flag, and removes the command from the queue.
$wAIT = false
$cmdqueue.delete_at(0)
# now that THAT command is completed, check to see if there is
# another command ready to transmit.
log ($green + "Command Completed.  Checking queue" + $grey)
if $cmdqueue.nitems > 0 then
log("Queue:" + $aqua + $cmdqueue.nitems.to_s + $grey + " : executing next command")
SndIns()
else
log($yellow + 'Queue Empty.' + $grey)
end
end
def checkWait(param)
#Checks for response from current command.
if $cmdqueue[0] != nil
else
log('------:)----checkWait: command queue is emtpy')
if $wAIT == true #this should never happen
log('------:(XXX-CheckWait: TRUE')
end
end
end

def plmparse(value)
#THIS ROUTINE REPLACES parsestring()
#this routine will PARSE the incoming stream into valid messages
# value is the complete command
param = {}

  while value.length > 2
case value[1]
when '62'.hex # Special case, need to look at flags
if (value[5] & '10'.hex) == '10'.hex # check for extended flag
cmdlen = 23
else
cmdlen = 9
end
param['Response'] = 'SndIns'
when '50'.hex; cmdlen = 11; param['Response'] = 'InsStdMsg'
when '51'.hex; cmdlen = 25; param['Response'] = 'InsExtMsg'
when '68'.hex; cmdlen = 4 #Set Insteon ACK Message Byte
when '71'.hex; cmdlen = 5 #Set Insteon ACK Message Two Bytes
when '70'.hex; cmdlen = 4 #Set Insteon NACK Message Byte
when '63'.hex; cmdlen = 5; param['Response'] = 'SndX10'
when '52'.hex; cmdlen = 4; param['Response'] = 'X10Msg'
when '61'.hex; cmdlen = 6; param['Response'] = 'SndGrp'
when '56'.hex; cmdlen = 7; param['Response'] = 'GrpEvntRpt'
when '58'.hex; cmdlen = 3 #All-Link Cleanup Status Report
when '64'.hex; cmdlen = 5; param['Response'] = 'StLnk'
when '65'.hex; cmdlen = 3; param['Response'] = 'CancelLnk'
when '53'.hex; cmdlen = 10; param['Response'] = 'InsLnkSts'
when '69'.hex; cmdlen = 3; param['Response'] = 'GetLnk'
when '6A'.hex; cmdlen = 3; param['Response'] = 'GetNext'
when '6C'.hex; cmdlen = 3 #Get All-Link Record for Sender
when '57'.hex; cmdlen = 10; param['Response'] = 'LnkData'
when '6F'.hex; cmdlen = 12; param['Response'] = 'MngLnk'
when '67'.hex; cmdlen = 3; param['Response'] = 'RstPLM'
when '6B'.hex; cmdlen = 4; param['Response'] = 'SetCfg'
when '60'.hex; cmdlen = 9; param['Response'] = 'GetVersion'
when '66'.hex; cmdlen = 6 #Set Host Device Category
when '72'.hex; cmdlen = 3 # RF Sleep
when '54'.hex; cmdlen = 3; param['Response'] = 'BtnRpt'
when '6D'.hex; cmdlen = 3; param['Response'] = 'LEDON'
when '6E'.hex; cmdlen = 3; param['Response'] = 'LEDOFF'
end

#Now we know the length the command should be, see if we have it.
if value.length >= cmdlen
#Yes, we have the whole command, Pack it in param
for byt in 1..cmdlen
param['Parameter' + byt.to_s] = padhex("%X" %value[byt - 1])
end
#now remove it from the string..
value = value.slice(cmdlen, value.length - cmdlen)
#Send it off for parsing
EZToDCE(param)
else
#no, we have NOT received the whole command.
return value
end
  end
return value
end




def rawX10(value)

x10MSN = $X10HouseCodes.index[value[0..0]]
x10LSN = $X10UnitCodes.index[value[1..1]]
return x10MSN + x10LSN
end

def X10Flag(value)
  return + $X10CommandCodes.index[Value] + '0'
end

def SndIns
# create a new PLM command for SndIns
if $wAIT == false
param = $cmdqueue[0]
### have to figure out the command byte 2 here
work = '02'.hex.chr + plmcommand(param)
### PLM command compilation
for loop in 2..param.keys.nitems
  @dummy = param['Parameter' + (loop - 1).to_s].to_s
  work+= @dummy.hex.chr
end
conn_.Reconnect()
debug(work)
conn_.Send(work)
#sleep 0.1
$wAIT = TRUE
else
log('X-----------SndIns: Waiting for response to:' +  $cmdqueue[0]['Command'].to_s)
log('X-----------SndIns: Current Queue Length:' + $cmdqueue.nitems.to_s)
end
end
def plmcommand(param)
### this returns the proper Byte2 for the command.
case param['Command']
when 'GetVersion'; return '60'.hex.chr
when 'SndIns'; return '62'.hex.chr
when 'SndGrp'; return '61'.hex.chr
when 'SndX10'; return '63'.hex.chr
when 'GetLnk'; return '69'.hex.chr
when 'GetNext'; return '6A'.hex.chr
when 'BtnRpt'; return '54'.hex.chr
when 'GetCfg'; return '73'.hex.chr
when 'StLnk'; return '64'.hex.chr
when 'CancelLnk'; return '65'.hex.chr
when 'MngLnk'; return '6F'.hex.chr
when 'RstPLM'; return '67'.hex.chr
when 'SetCfg'; return '6B'.hex.chr
when 'LEDON'; return '6D'.hex.chr
when 'LEDOFF'; return '6E'.hex.chr
end
end

def debug(text)
  work = 'OUT:'

  for c in 1..text.length
    work += padhex("%X" %text[c-1]) + ' '
  end
  log($green + work + "Length:" + text.length.to_s + $grey)
end

def debugin(text)
  work = 'IN:'

  for c in 1..text.length
    work += padhex("%X" %text[c-1]) + ' '
  end
  log($red + work + "Length:" + text.length.to_s + $grey)
end

def padhex(hex)
if hex.length==1
hex = "0" + hex
end
return hex
end

def percenttohex(level)
# convert from percent to byte
return "%X" %((level.to_i * 2.56) -1).to_i
end

def hextopercent(level)
return (level.hex.to_i / 2.55).to_i
end

def log(line)
$log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
$log.puts "(***):" + line.to_s
$log.close
end


def checkChildRecordsinPLM()
# time to verify all children are in the PLM
#
# log('Total PLM Records:' + $plmdatabase.nitems.to_s)
# $plmdatabase.each{|record|
# log('Record: = '+ getIIDfromRecord(record) + ' Group:' + getGroupfromRecord(record))
# }

$childdatabases.each_key {|child|
if existsinplm(child) == false
log(child + ' needs to be added to PLM')
addtoplm(child)
else
log(child + ' exists in PLM')
end
@result = 'Child: ' + child + "\n"

for record in 1..($childdatabases[child].nitems - 1)
@result += 'Record:' + getIIDfromRecord(record)
if existsinplm(getIIDfromRecord(record)) == false
log(getIIDfromRecord(record) + ' needs to be added to PLM')
addtoplm(getIIDfromRecord(record))
else
log(getIIDfromRecord(record) + ' exists in PLM')
end
end
# log(@result)
}
end
def existsinplm(insteonid)

$plmdatabase.each{|record|
#log(insteonid + '==' + getIIDfromRecord(record))
if insteonid == getIIDfromRecord(record)
#log('TRUE')
return true
end
}
return false
end

def addtoplm(insteonID)
log('Adding ' + insteonID + ' to the PLM database...')
#This adds a record into the PLM
@insID = insteonID.split('.')
param = {'Command' => 'MngLnk',
'Parameter1' => '40', #control code -- add new record as Controller
'Parameter2' => 'C2', #All Link Record Flags AKA Record Control Byte
'Parameter3' => '01', #All Link Group
'Parameter4' => @insID[0], #HB
'Parameter5' => @insID[1], #MB
'Parameter6' => @insID[2], #LB
'Parameter7' => '01', #Link Data 1 ON-Level
'Parameter8' => '01', #Link Data 2 Ramp Rate
'Parameter9' => 'FF'} #Link Data 3 not used
$cmdqueue << param
SndIns()
end

def getIIDfromRecord(recordstring)
#this extracts the insteonID string from the record.
@idhb = recordstring[4..5]
@idmb = recordstring[6..7]
@idlb = recordstring[8..9]
@result = @idhb + '.' + @idmb + '.' +@idlb
return @result
end

def getGroupfromRecord(recordstring)
#this extracts the GROUP from the record.
return recordstring[2..3]
end
« Last Edit: December 22, 2007, 10:33:27 pm by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Insteon PLM code for PeteK
« Reply #2 on: December 22, 2007, 10:30:22 pm »
Code: [Select]
#### Written by Dan Damron
#### #351 Process IDLE ####
############################ RECEIVE Error Trap ###########################
if  $cmdqueue.length != 0
if $resetNext != 0
log($redBack + 'receive timeout='+$resetNext.to_s + $blackBack)
end
if $cmdqueue.to_s == $savedstate
if $resetNext == 2
#Command has stalled. Reset wait flag and resend command.
log('Command Stalled!  resetting and retrying')
#hack to reset the command
if $cmdqueue[0]['Command'] == 'InsStdMsg'
$cmdqueue[0]['Command'] = 'SndIns'
end
$wAIT = false
$resetNext = 0
SndIns()
else
$resetNext +=1
end
else
$resetNext = 0
$savedstate = $cmdqueue.to_s
end
end
###########################################################################


#350 - Process Incoming Data

Code: [Select]
$recvbuff = ""
while(true)
buff=conn_.Recv(128,100)
if(buff.length() == 0)
break
end
$recvbuff = $recvbuff + buff
end
debugin($recvbuff)
plmparse($recvbuff)

Code: [Select]
#### Written by Dan Damron
#### #384 Process Receive Command for Child ####


log('------dce--- PRCFC:$wAIT=' + $wAIT.to_s)
#add DCE command to DCE queue




insteonID = device_.childdevices_[cmd.devidto_].devdata_[12].chomp.split('.')
###
#log('INSPECT:'+ device_.childdevices_[cmd.devidto_].devdata_[])
###
$cmdID = cmd.id_
$cmdTo = cmd.devidto_
childType = device_.childdevices_[cmd.devidto_].devtemplid_
$cmdFrom = cmd.devidfrom_
$cmdPriority = cmd.priority_
$cmdType = cmd.type_
$cmdParams = cmd.params_
log('------dce--- cmdID:' + $cmdID.to_s + ', cmdFrom:' + $cmdFrom.to_s + ', cmdTo:' + $cmdTo.to_s + ', cmdType:' + $cmdType.to_s + ', Priority:' + $cmdPriority.to_s)
$cmdParams.keys.each {|p| log('------dce--- Param_[' + p.to_s + ']=' + $cmdParams[p])}
case cmd.id_
when 192 # ON
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!!!"


param = {'Command' => 'SndX10',
'Parameter1' => rawX10(device_.childdevices_[cmd.devidto_].devdata_[12]),
'Parameter2' => X10Flag('On')}
$cmdqueue << param
SndIns()
end
# resp = Command.new($cmdTo, 1, $cmdPriority, $cmdType, $cmdID)
# resp.params_ = $cmdParams
# SendCommand(resp)
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!!!"
param = {'Command' => 'SndX10',
'Parameter1' => rawX10(device_.childdevices_[cmd.devidto_].devdata_[12]),
'Parameter2' => X10Flag('Off')}
$cmdqueue << param
SndIns()

end
# resp = Command.new($cmdTo, 1, $cmdPriority, $cmdType, $cmdID)
# resp.params_ = $cmdParams
# SendCommand(resp)

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
log "X10 DEVICE!!! relative Dimming command"
# have to send 2 commands
#param = {'Command' => 'SndX10',
#'Parameter1' => rawX10(device_.childdevices_[cmd.devidto_].devdata_[12]),
#'Parameter2' => $X10CommandCodes.index['Bright'] + $X10UnitCodes.index[dim_level]
#$cmdqueue << param
#param = {'Command' => 'SndX10',
#dim_level = ((cmd.params_[76] * 16 + 1)/100).to_i.to_s
#'Parameter1' => rawX10(device_.Childdevices_[cmd.devidto_].devdata_[12]),
#'Parameter2' => $X10CommandCodes.index['Dim'] + $X10UnitCodes.index[dim_level]}

SndIns()

end
# resp = Command.new($cmdTo, 1, $cmdPriority, $cmdType, $cmdID)
# resp.params_ = $cmdParams
# SendCommand(resp)
end
« Last Edit: December 22, 2007, 10:34:37 pm by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Insteon PLM code for PeteK
« Reply #3 on: December 22, 2007, 10:31:25 pm »
Code: [Select]
#### Written by Dan Damron
#### #355 Process Initialize ####
$red = 0x1b.chr + '[31m'
$green = 0x1b.chr + '[32m'
$yellow = 0x1b.chr + '[33m'
$blue = 0x1b.chr + '[34m'
$purple = 0x1b.chr + '[35m'
$aqua = 0x1b.chr + '[36m'
$grey = 0x1b.chr + '[37m'
$redBack = 0x1b.chr + '[41m'
$greenBack = 0x1b.chr + '[42m'
$yellowBack = 0x1b.chr + '[43m'
$blueBack = 0x1b.chr + '[44m'
$purpleBack = 0x1b.chr + '[45m'
$aquaBack = 0x1b.chr + '[46m'
$greyBack = 0x1b.chr + '[47m'
$blackBack = 0x1b.chr + '[48m'
$remoteLinkRecord = ''
#$remoteRecordReady = 0
$configstring = ''
$configparams = []
$childdatabases = {}
$plmdatabase = []
$plmlastrecord = true
$log = ''
$cmdTo = ''
$cmdFrom = ''
$cmdPriority = ''
$cmdType = ''
$cmdID = ''
$cmdParams = {}
$children = {}
$recvbuff = ''
$wAIT = false
$currentCmd = {}
$flagsBroadcastMessage = 128
$flagsDirectMessage = 0
$flagsAckDirectMessage = 32
$flagsNackDirectMessage = 160
$flagsGroupBroadcaseMessage = 192
$flagsGroupCleanupDirectMessage = 64
$flagsGroupAckDirectMessage =96
$flagsGroupNackDirectMessage = 224
$cmdqueue = []
$currentcmd = 0 # to save state of command when receiving more data.
$resetNext = 0 # used in Process IDLE to trap stalled responses.
$savedstate = nil
$dcequeue = []
$X10HouseCodes = {
'6', 'A',
'E', 'B',
'2', 'C',
'A', 'D',
'1', 'E',
'9', 'F',
'5', 'G',
'D', 'H',
'7', 'I',
'F', 'J',
'3', 'K',
'B', 'L',
'0', 'M',
'8', 'N',
'4', 'O',
'C', 'P'}
$X10UnitCodes = {'6', '1', 'E', '2', '2', '3', 'A', '4',
'1', '5', '9', '6', '5', '7', 'D', '8',
'7', '9', 'F', '10', '3', '11', 'B', '12',
'0', '13', '8', '14', '4', '15', 'C', '16'}
$X10CommandCodes = {'6', 'All Lights Off', 'E', 'Status = off',
'2', 'On', 'A', 'Pre-Set Dim',
'1', 'All Lights On', '9', 'Hail Ack',
'5', 'Bright', 'D', 'Status=on',
'7', 'Extended Code','F', 'Status Request',
'3', 'Off', 'B', 'Pre-set Dim',
'0', 'All Units Off', '8', 'Hail Request',
'4', 'Dim', 'C', 'Extended Data(analog)'}
$responseString = '<' + '/' + 'Response>'

############################## TEST Code below #################################
# testing Reading a devices Database
# Common Insteon Device Memory Locations:
# 0x0001 EESize - MSB of size of EEPROM chip in device
# 0x0002 EEVersion - Firmware Revision number
# 0x0020 EEOnLevel - Preset On-Level for lighting control
# 0x0021 EERampRate - Ramp Rate for Lighting Control
# 0x0030 EEX10BaseHouse - Base X10 House Code for device
# 0x0031 EEX10BaseUnit - Base X10 Unit Code for device
#
# ALDB/L
# Starts at the top of external serial eeprom and grows downward.
# most limited-memory INSTEON devices, top of memory is 0x0FFF
# Each Record is 8 bytes long, so the first record starts at
# 0x0FF8, the second record starts at 0x0FF0
#
# ALDB/L Record Format:
# Record Control: 1 byte
# Group: 1 Byte
# ID: 3 Bytes HB MB LB
# Data1: 1 Byte Link-specific data (eg. On-Level)
# Data2: 1 Byte Link specific data (eg. Ramp Rates)
# Data3: 1 Byte Link specific data (normally unused)
#
# Record Control Byte Bitmap:
# 7: 1=Record in use, 0=Record is available
# 6: 1=Controller of ID, 0=Responder of ID
# 5: Product Dependant
# 4: Product Dependant
# 3: Product Dependant
# 2: Product Dependant
# 1: 1=Record has been used before, 0=High water mark (last record)
# 0: Reserved

#PLM cat 03 subcat 05
# param = {'Command' => 'StLnk',
#'Parameter1' => '01', #Link code 0x01=controller
#'Parameter2' => '8F' #All Link Group
#}
#$cmdqueue << param
# param = {'Command' => 'CancelLnk'}
#$cmdqueue << param
#SndIns()
#
#Lets try the Assign to ALL-Link Group ### SUCCESS!!!
#param = {'Command' => 'SndIns',
#'Parameter1' => '0A', #HB
#'Parameter2' => '8F', #MB
#'Parameter3' => '5A', #LB
#'Parameter4' => '0F', #Flags
#'Parameter5' => '01', #Cmd1
#'Parameter6' => '8F' #Cmd2
#}
#$cmdqueue << param
#SndIns()
### Now to add record to the IM using 0x6F Manage All Link Record
#EZBridge command is MngLnk

#This gets NACKED probably because it already exists..
#but Group 8F should not exist...
#put IM in monitor mode..
param = {'Command' => 'SetCfg', 'Parameter1' => '40'}
$cmdqueue << param

param = {'Command' => 'MngLnk',
'Parameter1' => '00', # Control Code
'Parameter2' => 'C2', #All Link Record Flags AKA Record Control Byte
'Parameter3' => '01', #All Link Group
'Parameter4' => '0A', #HB
'Parameter5' => '97', #MB
'Parameter6' => '0B', #LB
'Parameter7' => '01', #Link Data 1 ON-Level
'Parameter8' => '01', #Link Data 2 Ramp Rate
'Parameter9' => '00'} #Link Data 3 not used
$cmdqueue << param
## Test Device: LampLinc ID:0A.97.0B
# Assign Test device to Group
param = {'Command' => 'SndIns',
'Parameter1' => '0A', #HB
'Parameter2' => '97', #MB
'Parameter3' => '0B', #LB
'Parameter4' => '0F', #Flags
'Parameter5' => '01', #Cmd1
'Parameter6' => '01' #Cmd2
}
$cmdqueue << param


############################## Real Code below #################################
#log('MY DEVICE:' + device_.devid_.to_s)
#################################################
#What I need to do and the order I need to do it.
#done read PLM database
#done get child devices
#done read child devices configuration
#done all child devices in the PLM database?
#done1 if not, add their ID to the PLM database (new group numbers?)
# get the status of each (child) device
# compare the Database delta with the value stored in the configuration
# Different?
# read the child database
# update configuration
# check devices links to see if any are new
# new link found, what to do?? send a message?
# possibly create new child device?
# Add new link to PLM
# PING the new device and back to 1
###
# easiest way?.. create hash for PLM records
# create hash for child devices is needed
# (not needed if DBDelta is same)


#get PLM database
getLnk

#get Child devices
log('Finding Children..')
device_.childdevices_.each{|c| $children[device_.childdevices_[c.to_s.to_i].devdata_[12].chomp.lstrip.rstrip] = c.to_s.to_i}
$children.keys.each{|c| log(c + ' = ' + $children[c].to_s)}
log('Getting Child configuration:')

$children.keys.each{|c|
#Get each Childs configuration
getdeviceconfig(c)
#the above getdeviceconfig packs $configparams array
log('Configuration for ' + c + ' = ' + $configparams.inspect.to_s)


# insteonID = c.chomp.split('.')
# param = {'Command' => 'MngLnk',
# 'Parameter1' => '00', # Control Code
# 'Parameter2' => 'C2', #All Link Record Flags AKA Record Control Byte
# 'Parameter3' => '01', #All Link Group
# 'Parameter4' => insteonID[0], #HB
# 'Parameter5' => insteonID[1], #MB
# 'Parameter6' => insteonID[2], #LB
# 'Parameter7' => 'FF', #Link Data 1 ON-Level
# 'Parameter8' => 'FF', #Link Data 2 Ramp Rate
# 'Parameter9' => '00'} #Link Data 3 not used
# $cmdqueue << param
}


## Test Device: LampLinc ID:0A.97.0B

## test remoteGetlnk
#remoteGetLnk('0A.97.0B')
## test remoteGetNext
#remoteGetNext('0A.97.0B')



##children found... get the status of each child...
#$children.keys.each{|c|
# if c.length > 2 #filter out X10 for now
#   #pack insteon message here, and send it out!
# # receive message in parsemessage and relay commands back in it.
# insteonID = c.chomp.split('.')
# param = {'Command' => 'SndIns',
# 'Parameter1' => insteonID[0],
# 'Parameter2' => insteonID[1],
# 'Parameter3' => insteonID[2],
# 'Parameter4' => '0F', #flags
# 'Parameter5' => '19', #Status Request
# 'Parameter6' => '00'} #not used.
# $cmdqueue << param
## below gets the device Cat/SubCat/Firmware
# param = {'Command' => 'SndIns',
# 'Parameter1' => insteonID[0],
# 'Parameter2' => insteonID[1],
# 'Parameter3' => insteonID[2],
# 'Parameter4' => '0F', #flags
# 'Parameter5' => '10', #PING
# 'Parameter6' => '00'} #not used.
# $cmdqueue << param
#
# end
# }
SndIns() #Lastly, start executing commands in order.
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Insteon PLM code for PeteK
« Reply #4 on: December 22, 2007, 10:40:32 pm »
Set up the template to match this:
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Insteon PLM code for PeteK
« Reply #5 on: December 24, 2007, 10:27:23 am »
This code is getting too big to post here.
I'm going to do code updates via email for anyone who wants them..
Simply PM me.
PeteK, if you can contact pluto.. I think I'm pretty much ready for them to bang in..

Thanks

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.