Archive for June, 2008

One of the best devices that I like which is included with the Starter kit is the ControlLinc.  This little device contains 5 set of buttons which dim,brighten and do other wonder things.  But after a while I wanted to have one button to run my ‘end of day’ scripts.   So after poking around I found how to catch which button was pressed this way you can setup your on or off button to various functions, basically doubling the options on my device.

Here is how one of my devices look.  Sorry Im still working on the insert.

So now instead of only 5 (on/off buttons) I have a combination of on/off’s as well as toggle (on/off) 🙂

As mentioned in my previous blog, the idea is to catch the data and act upon it.  Here is a copy of the code i used today to trap the OnText events that come in from the Insteon device. You can see by depending on the CMD1 you can catch by ON/OFF/Fast ON/Fast OFF.  so basically we are going to trap when a OFF button is pressed and then capture which button is pressed and act upon it.

Remember you will need to link your controller with your PLC to work, even if your PLC wont turn anything on or off you still need it for your code to see the commands coming in. You can do this by using the TAP/TAP method or doing it by Software linking shown here.

The variable Addrfrom will hold the address of your Controlinc
The variable AddrTo will hold the address of your PLC
The variable CMD1 will hold the function (on/off/dim/etc)
The variable CMD2 will hold the button that was pressed for example 01 = 1st set of buttons,02,03,04,05 etc.
So for the example below lets say we want to capture the ‘END OF DAY’ button, which is the third ‘OFF button, from left to right. Pressing a OFF button will send
a command of #13 which will then call the function below and check for which Key (1-5) was pressed

The code below is the same I explained in the Software: Get Insteon / Talking to your PC – Part 2 & Software: Get Insteon / Talking to your PC – Part 1

A sample string coming in would look like this;

6/28/2008 8:55:18 PM receiveinsteonraw=04 01 02 03 11 22 33 11 03 ‘ This is a ON button #3 pressed
6/28/2008 8:55:18 PM receiveinsteonraw=04 01 02 03 11 22 33 13 03 ‘ This is a OFF button #3 pressed

Like mentioned before starting from the left to right, Hex values

04 ? Sorry – don’t know

01 02 03 is the ID of the ControlLinc

11 22 33 is the ID of my PLC

13 is the OFF command

03 is which key was pressed from left to right.

I just added to the checking of the ‘OFF’ button and expanded from there.

Public Sub sm_OnText(ByVal strInsteonStatus As String) Handles Sm.OnText
        Dim device, bytes, data
        Dim Group As String
        Dim var As System.Array

        Dim value, Addrfrom, Addrto, flags, Cmd1, Cmd2 As String
        var = Split(strInsteonStatus, "=")
        Select Case LCase(var(0))
            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)
                    Cmd1 = bytes(8)
                    Cmd2 = bytes(9)

                    ' ------------------------- MACROS FOR REGULAR ON (11)
                    If Cmd1 = "11" Then
                         Macro_Check_Btn_On(Addrto, Addrfrom, Cmd1, Cmd2, flags)
                    End If
                    '-------------------------- MACROS FOR DOUBLE ON (12)
                    If Cmd1 = "12" Then
                        ButtonsChanged = True
                        Macro_Check_double_On(Addrto, Addrfrom, Cmd1, Cmd2, flags)
                    End If

                    ' ------------------------MACROS FOR 'Off' command checks (13)
                    If Cmd1 = "13" Then
                        Macro_Check_Btn_OFF(Addrto, Addrfrom, Cmd1, Cmd2, flags)
                        ButtonsChanged = True
                    End If
                    ' ----------------------- MACROS FOR DOUBLE turned off (14)
                    If Cmd1 = "14" Then
                        Double_Turn_off(Addrto, Addrfrom, Cmd1, Cmd2, flags)
                        ButtonsChanged = True
                    End If
                End If
        End Select

 Public Function Macro_Check_Btn_OFF(ByVal Addrto As String, ByVal addrfrom As String, ByVal command1 As String, ByVal command2 As String, ByVal Flags As String) As Boolean

        If addrfrom = "010203" And Addrto = "112233" And command1 = "13" And command2 = "03" Then
            Endofday() ' Do my special functions!

        End If


Insteon is great and is extremely fast when turning on / off devices, but lets say you want to turn on 10 lights all at the same time?

This is what they call groups. Groups allow you to store in each individual device settings such as turn on, ramp rate commands, for a specific group #.

Let me give you a example,  Let say you want to be able to turn on all your master bedroom lights with one command.  What we would do is create a group number and all the devices which will be affected will have this same number and respond as (Responder) to the person sending the command.  Don’t worry its easier than it sounds.  Let me go thru the basics and you’ll see how its done.

First for starters easiest way is to use some sort of spreadsheet, place all your device from left to right and then fill out what you want to turn on.  Here is a example (I’ll explain what the numbers mean shortly).  This way I know what group will do what and who will be ‘affected’.  Then its very easy to program going down the list.

In my case I have for example, Group #15 (Its HEX) called “End of Day” and what it does is turn off all lights but and turn on the kitchen sink all with one command.  So I mapped out all my devices and put how they are to be affected.

On Level

As you can see my values are two sets of numbers (I’ll select #15 the 2nd value of (FF/1B)

The first stands for the OnLevel (In the case of the dimmers (0-100%) but note its a HEX value, and it runs from 0-255.  Here is a quick list which I use.

FF 255
F0 240
DC 220
C8 200
BE 190
B9 185
AF 175
A5 165
9B 155
8C 140
78 120
64 100
50 80
4E 78
4D 77
4B 75
3C 60
1E 30
00 0

This way if I want to do a 50% I would use the A5 value, since im using FF it stands I want full blast, 100%!.

You will have to play with these to get the best ‘setting’ for your environment.

You can set a device to turn on to a 0% value which is the same as off, for example I have a group setup to turn on the sink night light but all other devices in the group are set to a ONVALUE of 0! NEAT!.  But OFF is OFF, no mater what you set it to.  You can see the VB samples below.  Basically the commands are the same instead of calling a device you call a group.

So with group #15 you can see the first value of all the devices is 00 with the exception of the kitchen sink which is FF so when the group command is sent all devices are dimmed while the Kitchen sink is turned on, all at the same time, the effect is very cool.

Ramp Rate’s

The second value is the RAMP rate (This only applies to devices which can ‘DIM’, and sadly its not included on the ICON dimmers, this is one of the reasons of the price difference.) These special devices have 32 levels of Ramp rates, from .1 second (which is what it is on the Icon dimmers, to 9 minutes!!)  Here is the conversion of the HEX value to the RAMP time

1F 0.1 Seconds
1E 0.2 .
1D 0.3 .
1C 0.5 .
1B 2 .
1A 4.5 .
19 6.5 .
18 8.5 .
17 19 .
16 21.5 .
15 23.5 .
14 26 .
13 28 .
12 30 .
11 32 .
10 34 .
0F 38.5 .
0E 43 .
0D 47 .
0C 1 Minutes
0B 1.5 .
0A 2 .
9 2.5 .
8 3 .
7 3.5 .
6 4 .
5 4.5 .
4 5 .
3 6 .
2 7 .
1 8 .
0 9 .

So a value of 1F is instant on, a value of 0C is 1 minute, and a value of 08 is 3 minutes!!!  The effect is awesome!  Note that once you send the command to the device to turn on with a specific RAMP rate it will go on its own and you can send more commands to other devices… NEAT!  Better yet you can have different device in the same group with different ramp rates. You know where im going with that!!  What i’ve read on the post that a slow ramp rate will prolong the life of certain lights, in my case all are CFL’s so I only use RAMP rates for external decorations and maybe a light or two.

Lets setup a group!

Lets show you some screens so you can see how its done.

Like all other things Im suspecting there are other ways of doing this, but this the way ive learned to do it and has always worked for me.

  1. Download’s program which you can find under my “Programs to have” and install it.  Im suspecting its free since its right off their support page. Once installed go ahead and fire it up.
  2. I’ve found that the program works better if there isnt any activiting on the network, also if my dryer isnt ok. Lol,. So please disconnect any X10 transievers or other information which may confuse the program.
  3. Since the utility is used to program many devices lets make sure we select that we are programming our PLC, select the USE PLC followed by ‘Connect’
    If you get an error, make sure you SDM driver is loaded, it should load automatically if not. This is also available from the ‘Programs to have’ page.
  4. Select the “Manage Device Links”
  5. Now hit your caps lock as all values need to be capital and the devices ID need to have (.) between them, like in the sample.  (Here we go!)
  6. In the first red square you will be entering the device you want to control (or in this case add to the group)
  7. In the green square, we need to add what device will be controlling it or responding to it.  If the device is going to respond its command we would select ‘Responder Below’, so this means when I call the group command from the device in the green box, the device in the RED box will respond.  In the case of a Controller its backwards.Since Im using my PC to send out group commands, we can assume that the ‘Second Insteon ID’ field will always be my computer PLC address.  This of course can be any other item, this way you can have one device control another or vice-versa!   In the case of 3 way switches this is where you would have two entries on both devices, and each is a responder and controller of each other!!
  8. In the Yellow box is where we 1st define the On Level (In HEX) , followed by the 2nd box contains the RAMP rate, 3rd box .
  9. Enter a group number in HEX.
  10. The last option as mentioned before its a responder or controller.  For the sake of this example its Responder.
  11. Hit the ‘Create New Link’

11. And your SET!.

Now from your Code you can send a group ON command and watch the magic happen.  Here is example using the SendInsteonRaw command to turn on group #16

Sm.SendINSTEONRaw(“0D 51 32 00 00 16 CF 11 FF, 3) ‘ sEND broadcast group 16 ON (Command is #11)

Sm.SendINSTEONRaw(“0D 51 32 00 00 16 CF 13 00, 3) ‘ sEND broadcast group 16 OFF! (Command is #13)

Check out more commands here

Just replace the MAC address with the group number and presto, you can DIM you whole house, For example

Sm.SendINSTEONRaw(“0D 51 32 00 00 16 CF 16 00, 3) ‘ sEND broadcast group 16 DIM!  (Command is #16)

Sm.SendINSTEONRaw(“0D 51 32 00 00 16 CF 15 00, 3) ‘ sEND broadcast group 16 Brighten!  (Command is #15)


There is a catch to group commands, that they WONT RETURN THE STATUS OF THE INDIVIDUAL ITEMS,  you will only get a response that the command to the group was sent successfully.  In my case I usually send the command twice to make sure they all are hit. 🙂

The first 3 sets of digits are my PLC, the next three are the group number

CF = ?

11 = the On Command

FF = the On Value

Like mentioned before, depending on your device and your RAMP rate settings the device will fade on, ICON switches will just jump to the level you have then set to.

For my program I have groups setup for

  1. Turn on/OFF all house lights
  2. Turn on/off both children’s room
  3. Turn on/off all external/indoor decorations
  4. Turn off all bathroom lights
  5. Turn off all lights but turn kitchen sink on
  6. Movie scenes Dim lights etc.
  7. Turn on/off all fans (We’ll get to that later using the Inline Linc’s)
  8. The sky’s the limit

You are of course limited to the amount of groups, depending on the device, for example the ICON’s will hold less groups but I doubt you’ll use them all.  🙂

Using this program is where I also link the device to the PLC so I can catch the commands coming in if I cant use the TAP/TAP method, for example I want to see when someone turns off a device, I would do everything the same except I would select ‘Controller’.  Even thought the switch really doesn’t turn on anything on my PLC I need to have that ‘group’ setup so I can capture it in my  code. 🙂

Good luck!

A Quick list of good Insteon Programs

SmartLabs Device Manager for the PLC (USB and Serial) – Install this one first.

Contains the Windows drivers for USB / Serial devices for the PLC.

InHomeFre – INSTEON Home Control Freeware

Excellent tool for setting up new items for the PLC to recognize it, also excellent for monitoring your Insteon traffic, I used this program to capture the commands

which I eventually incorporated into my code.  The program also is great for Serial / or USB devices which can save timers, and set other device settings.
For my project I bypass them since I basically use my PC,  but for starters this is a must have. Also does the same for X10 devices and full monitoring of all the data A++’s utility

Another priceless utility, this one I used for setting up, or modifying  my groups or scenes. Another neat tool is the ability to checking on what devices are linked.  This is also used for setting up all the’s devices.

One thing I was always interested was being able to notify me when a certain person calls.  And in this case flash a inteson light or two.

My code is in VB 2005, for a VB6 Sample you can go here and basically requires only some little coding.  In the case of VB6 I think you only need to add the Serial object and adjust the port via the objects property settings.

What I used,

  • Analog phone with Caller ID (Vonage actually)
  • Internal / External Modem – Mine is a 56k External modem and have caller Id capability.
  • Hook them up, from the wall to the modem, to the modem to the handset.  🙂

The best way to see if it does is to open Hyper terminal and type the following command AT #CID=1 if it respond’s ok your set. This of course if for the modem i’m using, depending on your device it may be different.  This page includes how you can check for Caller ID capability on your modem

Here is a example of what the modem will pickup and we will parse.


DATE = 0621

TIME = 1113
NMBR = 1407xxxxxxxxx
NAME = Carlos Cobol

If you modem is external like mine you need to make sure AutoAwnser is disabled this is done by the DIP switches, For the US robotics its Dip switch #5 as down. In the case its internal you will need to add the command to disable auto answer. This is done with the command ATS0=0.

My Dip settings are as follows,









Since the code below allows to send some strings up startup, just add the in there if you need to.

Note: I do make reference to textbox called txtDataReceived in my form which will include the output.

First we make our imports include the serial devices (My program writes to a SQL database so some lines may not be needed)

Imports System.IO
Imports System.IO.Ports
Imports System.Net
Imports System.Data
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Threading

In our Class definitions we include the reference to the serial port and we’ll call it ‘Modem’

Public Class Form1
    Dim WithEvents Modem As New IO.Ports.SerialPort

In our Load event we will attach to the serial port and give it the basic settings, Here is where you would also add any initialization commands

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Modem.PortName = "COM1"
        Modem.BaudRate = 9600
        Modem.DataBits = 8
        Modem.Parity = Parity.None
        Modem.StopBits = StopBits.One
        If Modem.IsOpen = False Then Modem.Open()

    End Sub

Next using the “Data Received” event we want to capture the Data which was received, Since there is a thread already running it wont allow us to update the textbox so simple we need to call use using the definition below,

 Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Modem.DataReceived

            txtDataReceived.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {})
        Catch EX As Exception
        End Try
    End Sub

Second function to update the textbox and check for the number, and check for one of the text information above, Ive stripped my code for simplicity but you can search for specific strings here, match it with fields in a database, even FTP the data somewhere else, but that i’ll show you on another post.
Here we will check for the number ‘123456789’

 Public Sub updateTextBox()
        Dim temp As String
        With txtDataReceived
            .Font = New Font("Garamond", 12.0!, FontStyle.Bold)
            .SelectionColor = Color.Red

            temp = Modem.ReadExisting.ToString
            Buffer = Buffer + temp
        End With

        If Buffer.Contains("NMBR") = True Then
            Dim FILENAME As String = "c:\cALLINFO.TXT"  ' - Set a filename
            File.WriteAllText(FILENAME, Buffer)    '---- Write all the buffer for testing if we want to see it
            If Buffer.contains("123456789") then   '----- check for specific #
                End If
        End if                  
End sub

I guess at the time of this writing Insteon there really isn’t a economical Insteon motion sensor out there, But after reading that the PLC and send and receive X10. I started to investigate further. And using inexpensive X10 devices I capture them and send out Insteon commands. 🙂

Just like with the insteon data you just have to phrase the information coming in.

As for hardware,  if you are using Motion sensors you NEED a X10 transceiver, this device is what will convert the signals sent from you motion sensor to X10 power lines signals that your PLC will pick up. Just go to Ebay and search for X10 Transceivers you will find them very cheap, I bought the one below for $10 with s & H!

Each transceivers will capture only 1 house code and up to 16 devices.
Here is a picture of my transceiver piggy back on top of my PLC. Since the motion sensors take 2 unit addresses, the more devices you will find you will need to add
in more but under another house code.

For the motion sensors, the same thing, go look for X10 motion sensor (The Eagle) are very inexpensive and great!!)
The go for about $5-6 each, and their weather proof!

Here is one I have outside the entrance (Painted with same color)

You can even have 2 eagle sensor with the same code to cover a big area like in my case my hall way which is in a “L” shape
so it will turn on the lights when ever it detects people in either direction. 🙂


Before we start, I recommend reading the previous threads here so you know how to setup and ‘capture’ the PLC text using VB 2005.  If you new to X10 and just started reading from here, please check out my first blog related to the X10 house code / unit code, found here

Like all my code, IM SURE there is many other ways but I just found it the easiest way for me. 🙂

Unlike Insteon, for some reason (I could be wrong) I cant seam to get all the information from one line, so I have to capture first the device that is talking, store the device in a variable then look further and see what its doing (on,off, etc)

For starters I use the same event for the ‘OnText’ event, Below is a sample text of a device that has been turned on which is read line by line from the OnText event

6/21/2008 4:16:46 PM eventraw=08   –  Means a X10 code was received
6/21/2008 4:16:46 PM receiveX10raw=00 EE  – The HEX value of the device (We wont use this)
6/21/2008 4:16:46 PM receiveX10=B2 – The device that is sending the code this can be A-G (House code) and 1-16 (Unit code)
6/21/2008 4:16:47 PM eventraw=08 –  Means another X10 code was received
6/21/2008 4:16:47 PM receiveX10raw=01 E2 – The HEX value for ON/OFf depending on device I use this to see if its on many time it can be 22/23 or E2/E3.
6/21/2008 4:16:47 PM receiveX10=B On – If the device was turned on, or off

Here is my code below (I’ve removed all Insteon and only left the x10 statements),  This is the main X10 routine I use to capture ALL devices and convert them to Insteon, for example remotes, key chains, motion detectors etc.etc.etc.

‘– I define a public variable called LastX10 this will hold the last HouseCode, Unit # in a variable that isnt lost when we leave the function.

‘- Somewhere in the start of your code,

Public Lastx10 As String

‘—– In the SM (SDM previously defined) OnText event.

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

      Dim var As System.Array
      var = Split(strInsteonStatus, "=")

        Select Case LCase(var(0))

                    ' -------------- GET DEVICE WHICH IS TRANSMITTING
            Case "receivex10"
                Dim variant1, variant2
                variant1 = Split(strInsteonStatus, "=")

                If (variant1(0) = "receiveX10") Then
                    Lastx10 = variant1(1)  '--------- Here I will store the X10 HouseCode and UnitNumber like (B2)
                End If

                '---------------------------------- SEARCH X10 CODES
            Case "receivex10raw"
                Dim variant1, variant2, strhousecode, strnumber
                variant1 = Split(strInsteonStatus, "=")

                If (variant1(0) = "receiveX10raw") Then
                    variant2 = Split(variant1(1), " ")
                    strhousecode = variant2(0)
                    strnumber = variant2(1)

                    If strhousecode <> 0 Then Checkx10codes(strhousecode, strnumber) '-------- Here I send the next commands to check all three LastX10,Strhousecode,strnumber)
                End If

Here is a example of the Checkx10codes which is called; Notice the strnumber variable changes when its on/off. Only way to find them for me is to test the device and capture

it, sometimes comes back as other numbers but the combination of the three variables is what makes it unique.

Public Function Checkx10codes(ByVal housecode As String, ByVal strnumber As String) As Boolean

  '------------- TURN ON/OFF HOUSE LIGHTS  --------------- C2
        If housecode = "01" And strnumber = "22" And Lastx10 = "C2" Then
            SendtoLog("*-- Keychain pressed to turn on house")
            StartofDay() ' - Some other function to turn on the lights
            Lastx10 = ""
        End If

        If housecode = "01" And strnumber = "23" And Lastx10 = "C2" Then
            SendtoLog("*-- Keychain pressed to turn off house with not activate")
            TurnOffHouse() ' - Another function to turn off all the house
            Lastx10 = ""
            Exit Function
        End If

End Function

Here are some more pictures of other X10 devices im using,

This 5 in 1 remote cost me $9 off Ebay. I have all my devices programmed in it, also

has EXCELLENT range to the x10 transceiver on the other side of the house! There is no DVD button but I programmed the
SAT button, and works great with my Brighthouse Digital box including the interactive guide!

See the device in action here controlling my living room fan / TV / light.

A couple of key chains, the one of the LEFT, keep away from it, the range is horrible, its a cool device for its
size and the fact is has 4 sets of buttons but, horrible range. I dont use it all.

The one on the right is EXCELLENT, highly recommended, you can get a set of 3 for like $12!!

Back side of one of my smaller remote, this one controls the light of the entrance which can be dimmed if I wanted to. So at the tip of my finger tips
I can dim both the garage and entrance lights of the whole outside house. Neat...

Backside of larger remote, Clear see though labels seem to stick
better than regular labels.  And by capturing each one of the button presses and the code above you can
then send out Insteon commands to the devices you want.  :)

For example on the main remote I have a button to call my children. Basically the program does the following,

For this to work each PC needs to have the Messenger service running which by default is off
Then from your code shell out to DOS, example below,


Here is what the batch file contains,

NET SEND * "Hi Girls, Your presence is requested in the living room.  THANK YOU"

I also blink the Living room lights with the following command (Basically four Insteon commands with a second delay between each)
For the example;  InD(16).MacSP="11 22 BB" which is the device address.

            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 12 FF", 3)   - ON
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 13 00", 3) - OFF
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 12 FF", 3) - ON
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 13 00", 3) - OFF


One of the cool things of the program is to be able to play sounds, and play other formats on-demand.  For this example we will play a chime clock at noon.

There are a couple of ways of doing this (API Calls, command line etc), The way I will show is for me the simplest way, and really only requires that you have windows media player installed.
If you are going to play MP3 files, you will also need to install the codec’s for it, the easiest way to do this is just download and install winamp (Free version).

1st Step is to make sure you Media player is setup and ready to go.

Note: Using the media player in the background allows me pause, get status, use playlists, set the volume and many other things, sure you can probably do this with API calls and other functions but the main purpose of my CPU power I want to dedicate to phrasing the executing Insteon commands.  Also besides being clean and simple, once the player is started you code will continue to run, it will not pause or stop while the media is playing. It will  only stop unless you tell it to, as well if you break the program.

Again using I was using VB2005 / XP, the first thing you will do is reference the object in your code.   Here is a picture of my reference.

We’ll use for our code the variable WMP and reference this,
In this case I refernce it twice so I have one for quick sounds and another for Internet Radio which can be playing all the time if needed, so they dont cancel each other out.

Public WMP As New WMPLib.WindowsMediaPlayer
Public WMP_Radio as New WMPLib.WindowsMediaPlayer

To point the player to the filename it actually called using the WMP.URL=”<full path to filename or source>” this can point to a streaming URL, Wav,.MP3 file even a saved playlist. (f.y.i. Playlist are simple text files which can easily be created if needed)

Here is the function I use to call the Media play and play a specific file, doesnt matter if its .WAV or .MP3, All my sounds are stored locally under C:\voicemail\sounds\ my function also passes the volume which ranges from 1-100. This is for the player not for the Windows Mixer.

Play_wav_file("doorchime.wav",100) - Play doorchime full blast!

    Public Function Play_wav_file(ByVal Filename As String, ByVal vol As Integer)
        WMP.URL = "c:\voicemail\sounds\" + Filename
        WMP.settings.volume = vol

    End Function

You can also test to see if the Media player is playing to prevent errors with its WMP.Status
Here are some others

WMP_Radio.controls.stop() - Will stop the player.

Here is my function to play Internet Radio, I can call it using various command such as

PlayMusic(“play80”) or PlayMusic(“stop”) etc…

 Public Function PlayMusic(ByVal cmd As String)
        Dim volume As Integer
        cmd = LCase(cmd)

        If cmd = "play80" Then
            WMP_Radio.URL = ""
            WMP_Radio.settings.volume = 30
        End If

        If cmd = "playsoft" Then
            WMP_Radio.URL = ""
            WMP_Radio.settings.volume = 20
        End If

        If cmd = "playhits" Then
            WMP_Radio.URL = ""
            WMP_Radio.settings.volume = 20
        End If

        If cmd = "stop" Then
        End If

        If cmd = "up" Then
            volume = WMP_Radio.settings.volume
            If volume <= 90 Then WMP_Radio.settings.volume = volume + 10
        End If

        If cmd = "down" Then
            volume = WMP_Radio.settings.volume
            If volume >= 10 Then WMP_Radio.settings.volume = volume - 10
        End If

    End Function

A very good link which I use for some of my sounds is, you will need to register to download them.

Yes, this is me around 20 years ago.  Enjoy!


Here is a collection of good Insteon ‘how to’ videos I found on youtube.

Installing a Smart-home dimmer switch, the same applies for the ICON switches even if they are the non-dimmable one’s. The wiring is basically the same for all others.

Setting the ‘ramp’ rate – This is the speed the light will turn on/off (Which is a very neat effect, but doesn’t apply to CFL’s)

Here is a sample of what RAMP rate is 

Sample of Switches in action

These can be control from .1 second to all the way to 9 Minutes!.

How to link Switches to devices (This applies if the light you want to control isn’t on the same switch), If you have a PLC or device which is controlled by your PC (like this whole project)  you will need to do this to be able to see the commands come into the PC.  Even thought the PLC wont respond to any command its a crucial step to see the traffic and be able to decode it.  Just treat your PCL as the device you want to control.

Part 2.

As requested, here are some live examples,  this is of course using the SDM library in VB 2005, the same works for VB6.
Since my blog is really about my home project, a VERY GOOD site,  which is the one I used to start which has lots of specs and examples in VB6 about these commands. Its called, I wouldn’t like to re-invent the wheel.

My examples are using the SDM.SendinsteonRaw command, I find them faster since you don’t wait for a return.  For our examples we can use the source as “00 00 00” or the actually # on the PLC and the
rate is the actual intensity of the command. you can also use the sm.SendINSTEON(Device ID,command 1, command 2,hops) but it will wait for a reply.  I like to catch the response on the way back. And example using that command would be
sm.SetOnLevelText(“07.B1.12”, “100%”) – And here you DO have to use the dots. 🙂  A list of most of the commands that can be used when the SDM is properly load are here

We’ll use as examples for our program that the device we want to control is

In our program previously defined,
You can download the SDM device manager here.  Also some information regarding the PLC can be found here (This is the one I have) – worth every $

Option Explicit on
Friend WithEvents Sm As SDM3Server.SDM3

 Public Sub MainMenu_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
 Sm = New SDM3Server.SDM3  - Create a instance of the SDM using (SM)

 Dim Mac as string = "11 22 BB"
 Dim Rate as integer = 255

Mac = “11 22 BB”
Rate = Intensity of the device (Since we are using raw commands this runs from 0,256 and needs to be converted to HEX”
The last #3, which is the Hops= I keep as 3 (Always works for me.)

Notes: All values are in HEX, also you need to put spaces in your device address, in my case I pull them off a SQL Database but they come in as “11 22 33” if you put (.) dots or any other characters the command wont work.

Turn onSm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 11 ” + Hex(Rate), 3) – Turn on device to the desired rate to 255 is the same as Sm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 11 FF“), 3) – Turn on 100%
This will turn on the device at the predefined RAMP rate so if you have setup a slow ramp rate this is the one to use.  For example ICON Dimmers have no ramp rate (options) so this will turn on at .1 seconds

Turn on fastSm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 12 ” + Hex(Rate), 3) – Turn on device to the desired rate to 255 is the same as Sm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 11 FF“), 3) – Turn on 100%
This will turn on the device at fast redgardless of the  predefined RAMP rate.

Turn offSm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 13 00″, 3)
This will turn off the device at the predefined RAMP rate so if you have setup a slow ramp rate this is the one to use.

Turn off fastSm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 14 ” + Hex(Rate), 3) – Turn on device to the desired rate to 255 is the same as Sm.SendINSTEONRaw(“00 00 00 ” + Mac + ” 05 11 FF“), 3) – Turn on 100%
This will turn on the device at fast redgardless of the  predefined RAMP rate. For example ICON Dimmers have no ramp rate (options) so this will turn off at .1 seconds

Brighten up one step sm.SendINSTEONRaw(“00 00 00 “+Mac+” 05 15 00″, 3)
Each device has 32 levels of so this will just bump down or up one.  Good for dimming without knowing the previous value.  You can dim to 0.

Dim down one step sm.SendINSTEONRaw(“00 00 00 “+Mac+” 05 16 00″, 3)
Each device has 32 levels of so this will just bump down or up one.  Good for dimming without knowing the previous value.  You can dim to 0.

Get status of device – sm.SendINSTEONRaw(“00 00 00 11 22 BB 05 19 00″, 3)
Using Alternet command sm.GetOnLevelText “11.22.BB”

Sending a Inteson group message; Groups allow you to send messages to a set of devices (1,2,10,100,200 with one command) Only bad things is you dont get a reply from the devices
I have found I had to run this twice sometimes but (We’ll get to groups later) .

Turn off group #20 (Remember HEX!) – sm.SendINSTEONRaw(“00 00 00 00 00 20 CF 13 00″, 3) ‘ SEND broadcast group 20 OFF!

Turn on group #20 – sm.SendINSTEONRaw(“00 00 00 00 00 20 CF 11 FF”, 3) ‘ SEND broadcast group 20 ON

The PLC also send X10 commands, for this I use theSendX10 command, this command WILL pause and wait for a response. For example

Sm.SendX10(“D02,DON”) ‘ TURN ON Device D02
Sm.SendX10(“D02,DOFF”) ‘ TURN ON Device D02

Lets say you want to check a email account every couple of minutes and this was react such as run a couple of commands and email you back?

For example I have already setup

  • Status checks of all lights
  • Turn on or off the whole house or individual lights
  • Randomize the house lights which will turn on my media player and play music remotely as well.
  • Open / close the garage,
  • Email me when movement is detected after I’ve turned the house off
  • The sky’s the limit.

What im currently using is outlook checking a pop3 account every 5 min, since Mapi interfaces really good with VB I use this. This way outlook itself checks every 5 minutes and you code just checks the email every 3. Again my code is Vb2005 / Windows

First setup outlook as your normally would, make sure it checks your email every 2-3 minutes. Then in your code, you will need to make sure you first reference the “Microsoft Office object 12 or 11 “ library into your code. Depends your version it may have object version 11 I’ve used this with Outlook 2000,2003,2007. I suspect by a macro you wont need to have outlook running but in my case its no biggie.

In your imports section include the following

Friend Class MainMenu

In your class definion add the following, i've commented each line

‘——– SET UP EMAIL goodies

Friend Class MainMenu
    Public inboxitem As Microsoft.Office.Interop.Outlook.MailItem  '--- we will use this object to send emails out
    Public objOutlook As Microsoft.Office.Interop.Outlook._Application ' --- Reference the outlook object, and load it if not already
    Public objNS As Microsoft.Office.Interop.Outlook._NameSpace '--------- The Outlook namespace, used throught the code.
    Public objInBox As Microsoft.Office.Interop.Outlook.MAPIFolder'------ The folder object that we will assign the inbox to.
    Public objItems As Microsoft.Office.Interop.Outlook.Items'-------- Each of the items in the inbox, we will loop thru this to read the individual emails.

Then once the program starts we need to set the session that will hold the connection to outlook, this is done in the Load event

Public Sub MainMenu_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
objOutlook = New Microsoft.Office.Interop.Outlook.Application()  '--- Assign the variable objOutlook to the application
objNS = objOutlook.Session '--------- Tie to the active session, if its not running it will load automatically

Then you can set a timer to check your email every certain amount of time executing the function CheckMail()

In the function that will do the actual reading, we will start with the assigning of variables and then check the emails and search for special text inside the body of the emails.

Public function Checkemail() as Boolean

objInBox = objNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox) ' --- Assign ObjInBox to map to the default inbox.
objItems = objInBox.Items.Restrict("[UnRead]=True") '----- assign individual items BUT filter only the UNREAD ones!

Dim outmail As Microsoft.Office.Interop.Outlook.MailItem  '---- This will hold the outgoing mail object
Dim iCount As Integer = objItems.Count  '------ Will hold the amount of NEW email, will return 0 if all email has already been read.

 For i = 1 To iCount

           inboxitem = objItems.Item(i)  '----------- ASSIGN A EMAIL ITEM TO THE INBOXITEM, from there we can query stuff like date,subject sender etc.
            If InStr(LCase(inboxitem.Body), "ouse on") > 0 Then  ' --- check for certain words in the Body, in this case 'house on' this also works for VB6
                Occupy() ' ---- Run another special function or code somewhere else

                '------ Here we create our reply email. ------------------
                outmail = objOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
                outmail.To = inboxitem.SenderEmailAddress '-------- Get the sender email for the inboxitem object.
                outmail.Subject = "* Reply"
                outmail.Body = "NICE TO HEAR FROM YOU, HOUSE ON. WAITING YOUR ARRIVAL."
            End If
 inboxitem.UnRead = False '- Mark email as read so its not checked twice next time
next i

Checkemail=True '----- Just to return something

End Function

And thats it!. If you like you can add attachments, HTML text and others, I would checkout Microsofts site for more details on what you can do with the outlook client!.


In my hallway I have a good ‘ol three way switch this is how I changed it. Just like in my previous entry, you can have switches controlling other switches by creating scenes. So a 3 way switch is basically that. Two switches controlling each other.

In 3 way switches you have a primary and secondary, the primary is the one which actually carries the load to the light fixture. The secondary just follows. But you may find the case (like me) where the secondary switch box doesnt have any power, since in traditional switches the power is fed from the primary.

Since there are a two wires connecting the primary to secondary (known as the traveler) we will jump the black wire to the line and use it to power the secondary switch. In my case it was easy to find the traveler wires since 1st it will be in a strand with 2nd traveler and it wont be with the line or neutral.

Once setup, and power ‘on’ you link both of them to each other and create a ‘scenes’ and each dimmer switch holds plenty of them, So you can with one switch control all the others (without needing a computer) , but not only turn on how about turn on to a certain level, and even control the ramp rate (Which is how fast the light turns on) – A very neat effect!. And presto you have created your virtual 3 way switch, the response is very fast. And technically you can add more if you like. I cant imagine a 10 way switch. 🙂 but technically you can do it, all this without a dedicated computer.

Here is the wiring diagram off the Smarthome page for it.


As for reading them in the program I just look for one of them, since eventually both will respond.

See ya