Archive for the ‘Non Insteon Programming’ Category

Here is a quick way that I reuse some of my lighting equipment depending on the season using individual components.   For example right now unless you order via the internet you can not find a good purple spot light.  And what I’ve experienced here in our FL weather many times your spot spike can rust and your investment is gone.

Also many of the spots are 100Watts which are real energy suckers and not to mention can get very hot.
So doing some searching and testing here is what I do.

Using a standard spike spot and cheap Daylight CFL bulbs, covered by a aluminum reflector and top it off with a colored lens. 🙂  Simple right?

Disclaimer: I am not a electrician and I only provide this info for entertainment, anything you do is at your own risk.

Here is the list
Light spike, Home Depot, and Lowe’s  and anywhere during holiday season  – $5-7
PAR 38 Spot aluminum reflector http://www.1000bulbs.com/Aluminum-Reflector-Options/31285/ $4.25 each  *
1 PAR 36 Lens Cover you can get these at Amazon.com-  $1.95
1 G/E Daylight 14 Watt bulb – (Walmart) 2 x $5  (Needs to be daylight not cool, bright or any other will not show the true color of the color lens)

Optional:
Green Spray Paint.  To cover the outside of the reflector to hide its appearance.

* Note:You may spend a little up front for shipping ($5-7) but once you have your items you can reuse them over and over.  Only part which may need replacing would be the bulb
or the spike which you can find at any hardware store.
* Also the size o the  aluminum reflector that fits perfect is the one shown above, the site has many others but many dont fit (Trust me)
* Due to the size of the CFL’s, when building you may need to put lens last.


Pros:
Very low power usage when using CFL’s.  For one traditional 100 Watts bulb you can use 6 of these spots. A++
Doesnt get very hot A++
Interchangeable parts, bulb goes out, swap the bulb and your set.  The spike/reflector/lens you can use over and over.
You‘ control the intensity adding the desired wattage bulbs.  If you lights are computer controlled you can even control dimmable CFL’s.

Cons:
For me only one really, No really designed for outdoor use, I used clear shipping tape to secure the top lens and has worked fine so far from water getting in, of course I don’t turn on any decorations or lights if its raining.

Do a search for the following items in Amazon and pick your colors!

PAR 36 Red Plastic Lens
PAR 36 Yellow Plastic Lens
PAR 36 Amber Plastic Lens
PAR 36 Purple Plastic Lens
PAR 36 Blue Plastic Lens
PAR 36 Light Green Plastic Lens
PAR 36 Dark Green Plastic Lens

Here are some pics of the finished setup

Finished product with the outside of the reflector painted green.

Blue – Always perfect for Halloween cemetery

Yellow


RED


PURPLE


AMBER (Mix between Yellow and Orange another Halloween favorite)

Sorry forgot to take the pic of the Green one… 😦  Enjoy!

Advertisements

Just thought I’d post this little tidbit.  When using Flash/action script to call the infamous ‘Loadvariables’ functions I have found that some browsers like IE like to grab cached results, for some reason it worked fine in Firefox but if you try to embedded IE in your programs you will run into the same problems.

In my case I call the same function and the server side takes care of the action.  And if your like me you may be calling the same page more than once quickly.  This issue got me for days, and worked on some computers and other didn’t.

So when calling your pages just add a fictional variable not used by your pages, I called my cache_buster and add ‘date’ and ‘time’  to get a 8-15 character number that should be unique, tricking the browser you are looking for a unique page and not grab from cache

loadVariables("http://192.168.0.2:85/finddata.aspx?show_all_configs=1&cache_buster="+new Date().getTime(), this);

If your like me who use Firefox on a daily basis most of your browsing.  You know it can be frustrating when you hit a Internal Sharepoint servers or a box which assumes your running IE and depends on NTLM, In our case as you know each time it will ask for your domain user-name / password.  We’ll Firefox does have NTLM just that you need to configure it which is really specify the boxes you will connect to.  Hey its not fully automatic but in my case works like a charm since I don’t connect to 1000 Sharepoint boxes.

NTLM stands for NT Lan Manager, but not the ol’ Lan manager software but instead Microsoft’s authentication protocol.    (These changes are done at your own risk)

Here we go, First launch Firefox and enter in the URL; about:config

This will expose all Firefox’s system settings

From there it will provide a long list of settings, on the ‘search’ bar type NTLM, you will see 3 entries, were just interested in one.

Double click on network.automatic-ntlm-auth.trusted-uris

From there you will enter the DNS name of your Server, in this case a Sharepoint server, since I only have one server Im suspecting you can enter more than one with a comma.

And presto, close firefox and re-open…

For email coming in and out, I use MS outlook, which makes interfacing with VB very easy.  But if you have configured the outlook client not using exchange, you know that you must specify the time in minutes it will poll to check for email.  Lets say you want to force it to check for new-email at your will.  Well this is how its done, but for this to work you must have the outlook client open.

If you havent please jump this article which shows how to setup your references and other goodies prior to this.

Software:Controlling Insteon devices using an email account

Back here so soon, great!

What are are doing is calling the Microsoft core command bar of the application itself and ‘press’ the button we want to execute, in this case

Were creating instances of the Controls, Tools – > Send/Receive and the account we want to poll. And I don’t have to wait for the application to hit its internal timer.
Sure you can let the timer run but in my case I have my MX records pointing home and host my own pop3 server, so once I get email I notify my server program (In another article soon) to force a scan of my email and act accordingly.  This makes the response to my emails lighting fast.!

So here’s the code,

Function ForceEmailcheck() as boolean

        '------------ Set up the Variables / Objects
        Dim oCtl As Microsoft.Office.Core.CommandBarControl
        Dim oPop As Microsoft.Office.Core.CommandBarPopup
        Dim oCB As Microsoft.Office.Core.CommandBar

        'Use the Send/Receive on All Accounts action in the Tools
        'menu to send the items from the Outbox, and receive new items for my specific account
        oCB = objOutlook.ActiveExplorer.CommandBars("Menu Bar")
        oPop = oCB.Controls("Tools")
        oPop = oPop.Controls("Send/Receive")
        oCtl = oPop.Controls.Item(6)   '----- Please see below why this is a #6 (*)
        oCtl.Execute()  

        '------ return something but not needed to work
        ForceEmailCheck = True
    End Function

* Since your this calls the name of the account itself for example (1.mail.xxxxxx.com) you will need to use that name for this to work, so I ended up using the item # and its easier.
The way to find this out is after you have set up your outlook, copy the above code in your VB and

set a break point at "oPop = oPop.Controls("Send/Receive")"

Then from your ‘Immediate window’ in VB do a query of the item of that control to see where your ‘send/receive’ for your specific account is, (Most likely #6 also)

?oPop.Controls.Item(1),
?oPop.Controls.Item(2)
?oPop.Controls.Item(3)
?oPop.Controls.Item(4)... etc...

Until you find the item you wish to ‘press’ and then insert the # above.    That is how I found the item I was looking for was #6.

And your Set!!

Luis,

One of the questions ive been asked is how to I put my flash script to grab data from the SQL database and provide updates if the device is on or off etc.

Well the awnser is, I dont. Like mentioned before to have your flash talk directly to a sql database you will need additional components which I dont want to install $$$, such as cold fusion or some advanced Flash stuff.  Again I want speed and functionality, especially if its only for a few users.

So what I did was use a internal web server which is installed with VB 2008, to do all the talking for me, more like a middle man.  for example my flash program talks to this web page using the ‘load’ function which sends data using the POST commands (example http://192.168.0.101/finddata.aspx&IN=14) and the code runs and returns the values needed in a specific variable in this case ‘VALUE’. you can also use the LoadVariables command which explain that in this article.

Flash:Loading Variables from files into Flash

So here is a high level of what is being done in the background.

All all times the Insteon Server is updating the SQL Server with the status of the devices as they are turned on or off, so we dont need to connect there. Also note that the Local .net, SQL database and insteon server are all on the same box!

For example lets say I want to pull the status of device #14. (Fan in master bedroom)  This is what I would do from the Flash Program

Example in FLASH CLIENT;

Prepare: In Flash you will need to create a empty movie clip called ‘fan_master’.  Also have images already in your webpage in the location mentioned below. I call it right of the same page you can use your local library if you like.

Here are my images I use in my Flash program,  you may use them if you like (Just right click on them and use SAVE AS)

Light_bulb_off.png

Light_bulb_on.png

Off Button (small_button_on.png)

On Button (small_button_off.png)

In my actionScript, I would put on one of the frames;

//--------------------- SETUP A NEW VARIABLE TO GRAB MY DATA THIS FUNCTION WILL RUN WHEN THE BELOW SITE IS OPENED
var mfan:LoadVars = new LoadVars();
    mfan.onLoad = function() {

//------ Here I check the return value that is returned back as 'value' if its is ON then replace the fan_master 'movie' to the bulb on image
          if (mfan.value=="ON"){
            loadMovie("http://192.168.0.101/images/small_button_on.png", fan_master);
        } else {
            loadMovie("http://192.168.0.101/images/small_button_off.png", fan_master);
        }
    };
//---------------- do the actual opening of the webpage and pass the variable IN and the device im asking for
mfan.load("http://192.168.0.101/finddata.aspx?in=14");
stop();

BLUE BOX (SERVER .NET SIDE)

A description of my Devices Database is found here

‘————————— VB 2008 / WEBPAGE filename finddata.aspx

On my Server side I would grab the value on “IN” using the

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      '------- Device will hold the value of in 'IN' which is #14
      device = Context.Request.Params("IN")
      value = Lg_Get_Device_Status(device)
      Response.Write("value=" + value)
 End Sub

This will return to my program the following text
“value=ON” or “value=OFF”

‘——– Function to grab the device data by the device #

    Public Function Lg_Get_Device_Status(ByVal Marker As String) As String

        Dim sqlConnection10 As New System.Data.SqlClient.SqlConnection(ConnectionSTring) ' Set your connectionstring accordingly.
        Dim Cmd10 As New System.Data.SqlClient.SqlCommand

        '-------- We'll use the SqlDataReader to get the values of the table 
        Dim Reader As SqlClient.SqlDataReader

        Cmd10.CommandText = "SELECT * FROM Devices where Marker= '" + Marker + "'"
        Cmd10.Connection = sqlConnection10
        sqlConnection10.Open()
        Reader = Cmd10.ExecuteReader()

        ' check for data, if not return 'FALSE'
        If Reader.HasRows = False Then
            Lg_Get_Device_Status = False
            Exit Function
        End If
        Reader.Read()
        '-------- RETURN THE VALUE FROM THE DATABASE SUCH AS ON OR OFF OF %
        Lg_Get_Device_Status = Reader.Item("status")
        sqlConnection10.Close()

    End Function

And there you have it, I do use the same file (finddata.aspx) for other stuff and you can easily query what is being passed and eventually act on it like this,

For example if I pass(showall=1) it would run another function, but that is another article.

        '------------------- SHOW ALL DEVICES
        If Context.Request.Params("showall") <> "" Then Show_insteon_devices() : Exit Sub

        '------------------- SHOW ALL DEVICES by MAC address
        If Context.Request.Params("showmacs") <> "" Then Show_insteon_devices_mac() : Exit Sub

        '------------------- SHOW ALL CONFIGS
        If Context.Request.Params("show_all_configs") <> "" Then Show_all_configs() : Exit Sub

In trying to consolidate all the PC’s and other OS I have at home into one machine I ran into a small problem.  First I was finally able to remove my good old 2k3 test server.  This server hosted Exchange, DNS, DHCP, and 5 webpages.  With that said, the pc replacing it only had XP on it and really was going to let my trusty D-link take care of DNS,DHCP and all the other goodies.  And I had no need to exchange

But once I came to migrate my webpages, XP’s IIS only allows you to run one webpage!?.  Ok np, all my webpages are PHP,MySql and other goodies so I really had no need for IIS nor .NET framework.  So I downloaded a copy of XAMP which has everything ready to go.  You can find that here.  This package includes

Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.

Its more than all the necessary tools in one easy to use program, and since all its components are free well its free for you to.

Go ahead and install it, you’ll have your webpage setup in no time!.  Lets say you have your router allowing port 80 out to the internet so you want to host more than one page (I’ll explain the port opening on another document).

For the example I have one page pointed to http://www.site1.com and http://www.site2.com on the same XP in windows

  • Install Xamp and test you can see the webpage.  In my case I installed it on F:\ drive which we’ll use from now on, you can use C:\ if you like. Coming for the server side, I keep my system files separate from the program files.
  • Look for your apache http.conf file, in my  case it was found here “E:\xampp\apache\conf”, open it with notepad.  Were going to give Apache permissions to the webpage root folder first.

Add the following lines in this case my files are located on E:/shared/WebSite-Live/site1_files and the second site on Site2_files

#--------------------------- MAKE SURE YOU GIVE ACCESS TO APACHE TO THE DIRECTORY 
<Directory "E:/Shared/WebSites-Live/site1_files">
  Order allow,deny
    Allow from all
</Directory>

#--------------------------- MAKE SURE YOU GIVE ACCESS TO APACHE TO THE DIRECTORY 
<Directory "E:/Shared/WebSites-Live/site2_files">
  Order allow,deny
    Allow from all
</Directory>

For the sake of simplicity we’ll allow All to view this folder.

  • Now we are going to go ahead and create the virtual host.  Look for this file called ‘httpd-vhosts.conf’ this can be part of the original http.conf file but is separated in the install of xamp , so we will modify that file directly, that is found ‘e:\xamp\apache\conf\extra’. Go ahead and open it with Notepad
#'---------The first section we will leave alone since its the main page, and will only load from the localhost 127.0.0.1
<VirtualHost 127.0.0.1>
 ServerAdmin webmaster@dummy-host.example.com
 DocumentRoot "e:/xampp/htdocs"
 ServerName localhost
 ServerAlias localhost
 </VirtualHost>
 #------------------- HERE WE SPECIFY THE SECOND VIRTUAL HOST WHICH IS OPEN TO EVERYONE
<VirtualHost *>
 ServerAdmin webmaster@dummy-host.example.com
 DocumentRoot "e:/Shared/WebSites-Live/site1_files"
 ServerName www.site1.com
 <Directory "e:/Shared/WebSites-Live/site1_files">
 Options All Includes Indexes
 </Directory>
 </VirtualHost>
 #------------------- HERE WE SPECIFY THE THIRD VIRTUAL HOST WHICH IS OPEN TO EVERYONE
<VirtualHost *>
 ServerAdmin webmaster@dummy-host.example.com
 DocumentRoot "e:/Shared/WebSites-Live/site2_files"
 ServerName www.site2.com
 <Directory "e:/Shared/WebSites-Live/site2_files">
 Options All Includes Indexes
 </Directory>
 </VirtualHost>
  • Either using the Xamp console or going to control panel then services restart your Apache service and your set!

Note: If your not exposing your Pc out into the internet you can still host more than one site, you may need to play with each PC’s ‘hosts’ file to point them to the PC hosting the sites.

Hi, in a previous article I had shown how to monitor & capture data on a specific port using VB. Mainly to allow my server send out notification to the clients, like a Caller ID Alert. That article can be found here

How to monitor and capture data in a specific port in VB / 2005

Below I’ll show the code I use on the server side to actually open and send the information to the clients.

Like mentioned above I will use the example of a caller Id alert , so the program will open a port 81 and send the text ‘callerid’ to the clients (In this case 192.168.0.106). You can use PC names if you have a home router like D-link etc.

Since I have a couple of clients I use VB ‘commandline’ feature to retrieve the IP, port and message that I am going to send.  My utility is called ‘BumpClients’.  For the example lets say this how its called

“Bumpclients.exe 192.168.0.106 callerid 81”

—————— Setting up the imports, make sure you include System.Net and System.net.Sockes, the others may not be needed

Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Xml.XPath
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Data
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1

'------------------------------ Create the instance to of the TCP Client (Its the same as receiving)
    Public WithEvents OpenPort As TcpClient  

'------ I use the Form_load event to quickly send the message and exit the program, no user interaction is needed, we grab all paramters from the command line when called.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Minimized '- Go hidden
        Me.Hide() '- Go hidden

'------ Next using the Split command I grab the three parameters by looking for the space( This will give me the IP,the command,and port the program will use!)
'------ Data(0)=IP, Data(1)=command, Data(2)=port.

        Dim IP As String
        Dim datA_out
        Dim port As Integer

        data_out = Split(Command$(), " ")
        IP = data_out(0)
        port = data_out(2)

'------ Just a quick check to make I can ping the IP, if not just exit and dont even bother.
        If My.Computer.Network.Ping(IP) = False Then End

'---- The actualy opening of the port un a 'try' statement if it fails exit also
        Try
            OpenPort = New TcpClient(IP, port)
        Catch
            End
        End Try

'------ If all is good then go ahead and convert our text to bytes and send it out using the stream method!
       Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(Trim(data_out(1)))

        Dim stream As NetworkStream = OpenPort.GetStream()
        stream.Write(data, 0, data.Length)

'------ Close and exit!- That's it!
        stream.Close()
        OpenPort.Close()
        End
    End Sub
End Class

A important note, remember that on your client you need to open the port you use in the firewall or it will never see anything, but you dont need to open it on the server since it will be sending.  To test this you will need the two actual computers sine you cant monitor and send data thru the same port.

In my application I actually run a external program using the system.diagnostics,process.start command, to the IP of my PC’s this way, it will run each script and not wait.And each of time will exit accordingly.

data_out=”callerid”
port=81

System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.102 ” + data_out + ” ” + port) ‘ Laptop
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.120 ” + data_out + ” ” + port) ‘
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.104 ” + data_out + ” ” + port) ‘

Enjoy!