Posts Tagged ‘x10 commands’

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,

System.Diagnostics.Process.Start("c:\wintools\CALLGIRLS_LIVINGROOM.bat")

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
            System.Threading.Thread.Sleep(1000)
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 13 00", 3) - OFF
            System.Threading.Thread.Sleep(1000)
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 12 FF", 3) - ON
            System.Threading.Thread.Sleep(1000)
            Sm.SendINSTEONRaw("00 00 00 " + InD(16).MacSP + " 05 13 00", 3) - OFF

Enjoy!
Advertisements