Another way of polling Insteon Devices via VB

Posted: August 24, 2008 in Software Setup
Tags: , , , , , , , , ,

Insteon’s SDM COM object is great for having a preset commands at your disposal but ive ran into issues where I dont want the program to wait for the ACK.  (In this case it will pause for the response), this can be a problem in very large environment, especially if your poll all devices at a certain time.  In my case I like to poll all the devices at least twice a day.

If this is the first article you ready please check out the articles below on how to get started.

Software: Get Insteon / Talking to your PC – Part 1

Software: Get Insteon / Talking to your PC – Part 2

For example

The SDM quick command is sm.GetOnLevelText “11.22.BB”

We will be using the InsteonRaw command Hex #19 like this
sm.SendINSTEONRaw(”00 00 00 11 22 BB 05
19 00″, 3)

Here is a debug of what is sent and what is received. I am polling device (0A.FE.3E) from my PLC (0D.51.32)

8/24/2008 11:38:32 AM sentinsteon=0D 51 32 0A FE 3E 05 19 00
8/24/2008 11:38:33 AM receiveinsteonraw=04 0A FE 3E 0D 51 32 21 00 00

Insteon responds in the same but with the device being queried first

0A FE 3E= Device responding.

OD 51 31 = My PLC, the desitation receiving the response

21 = Is a incremental # which can change among #21-2B, so you have to look for it.

00 = Some type of marker – Changes also

00 = Our value in hex, from 00= OFF to FF = Full all and everything in between

Here is another debug trace of a device query which is on;

8/24/2008 11:43:33 AM sentinsteon=0D 51 32 08 6B 57 05 19 00 (My requesting of status of the device calling command #19)
8/24/2008 11:43:34 AM receiveinsteonraw=04 08 6B 57 0D 51 32 26 1A FF (This one is reporting back as ON!)

Note: What is very tricky of this is that don’t always thing FF is on, I some icon dimmers that on can be ‘FE’, as a rule of thumb anything NOT 00 is consider for me as ‘ON’

Again all these codes are show in “Software: Get Insteon / Talking to your PC – Part 2“. I’ve copied the code from part #1 which will allow us to act upon the events of the SDM when text arrives back

'------- First we setup the SDM object in our code
Class  MainMenu
Friend WithEvents Sm As SDM3Server.SDM3

'-- When I load my mainmenu even I have the following

Public Sub MainMenu_Load(...... )
  Sm =New SDM3Server.SDM3
    MsgBox("SDM NOT LOADED try AGAIN")
 End Try
End Sub

Here is the TEXT event that I use for the whole program to break down and read the strings returned to me.

Public Sub sm_OnText(ByVal strInsteonStatus As String) Handles Sm.OnText

var = Split(strInsteonStatus, "=")
Select Case LCase(var(0))

	Case "setonleveltext"
		data = Split(var(1), ",")
		device = data(0)
		value = data(1)

	Case "receiveinsteonraw"
		data = var(1)
		bytes = Split(data," ")
		If LBound(bytes) = 0 And UBound(bytes) = 9 Then
			AddrFrom = bytes(1) & bytes(2) & bytes(3)
			AddrTo = bytes(4) & bytes(5) & bytes(6)
			Flags = bytes(7)
			Command1 = bytes(8)
			Command2 = bytes(9)
			End If

                    If flags = "21" or flags = "24" Or flags = "25" Or flags = "26" Or flags = "2B" Or flags = "22" Or flags = "23" Then
                        If Cmd2 <> "00" Then Msgbox "DEVICE IS ON!!"
                        If Cmd2  = "00" Then Msgbox "Device is OFF!"
                    End If
		End If
	Case Else

End Select


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s