I recently joined the HAI (Home Automation Incorporated) developer program and started messing with their SDK. I have managed an OmniPro II system for my boss, for several years, and recently purchased an HAI Omni IIe system for a house I am having built. Being that I’m a C# developer, I decided to tear down their example program, and start rebuilding it to suit my needs. Their example gives you the resources to connect to the system, get the basic configuration, and monitor certain functions within the home.

The only problem with this SDK example application is that they have a method called “HandleIdentifyController”, and it contains a check to see if the system in OmniPro II. If it is not, it simply throws the error “model does not match file”, and disconnects. Wow, a lot of good that does me. After a bit of research, and understanding behind the error, I came to find that within the HAC object (clsHAC instantiation), it is set to OmniPro II by default. I came up with a little snippet of code that will fix this problem.

Within this HandleIdentifyController method, are two sections depending on the protocol used to connect. You need to add this snippet of code to both sections, unless you don’t care about one of the protocols. The upper portion is UDP and the lower portion is TCP (Omni-link II).

There is a line of code

if (HAC.Model == MSG.ModelNumber)

Right before that line of code, add this:

foreach (enuModel enu in Enum.GetValues(typeof(enuModel)))
    {
        if (enu == MSG.ModelNumber)
        {
            HAC.Model = enu;
            break;
        }
    }

so it looks like this:

clsOL2MsgSystemInformation MSG = new clsOL2MsgSystemInformation(HAC.Connection, B);
foreach (enuModel enu in Enum.GetValues(typeof(enuModel)))
    {
        if (enu == MSG.ModelNumber)
        {
            HAC.Model = enu;
            break;
        }
    }
if (HAC.Model == MSG.ModelNumber)
{...}

What this does is loop through available system types within the HAI SDK, and tries to match it to a system type. If it can’t match it, it will continue to throw the same “model does not match file” error. This means the SDK does not support that system.

Advertisements

Just over 10 years ago, I bought my current townhome brand new, and wanted to have all kinds of automation in the house for lights and other stuff. I had a few X10 devices, which worked fine in my apartment at the time, so I stocked up and bought a few more before I moved into the new place. After moving in, I tried setting up X10 stuff, and it worked for awhile. After a bit, I started noticing lights randomly turning on and off. Then plug in switches started to fail, my fireplace started turning on randomly. Then suddenly, pretty much everything stopped. It seemed as if x10 items that are on the same circuit, work great, but if they are on different breakers, even if on the same phase, they didn’t work. For years I have used a simple X10 motion detector with the receiver used as an appliance module, to turn on my garage lights when I walk out to the garage. It works well because there’s no powerline usage. I was always disappointed, and I have a box with a few random X10 items that are brand spankin’ new.  Disappointing. So, I gave up on that adventure.

Several years ago, my boss came to me with a project to pick a home automation system for the new house he was having built. I looked at many systems from Crestron, to Control 4, to HAI, and other smaller names. Eventually, the pick came down to the HAI OmniPro II system, for several reasons. It can do most of what the super expensive systems can do, but at a much lower price point, and has the reliability of UPB. So, we chose the HAI system, and installed it in his new place. We integrated whole house audio, lighting on nearly every switch, security, video, motion detection, and blinds control. He has a button “Go to work” that will turn off all the lights and audio, open the blinds all the way so his plants get lots of light, and arm the security system. He had his basement done, and we wired in 2 outlets for a mirror ball, and a laser show. A button called “Dance” dims the lights very low, and turns on the mirror ball, laser show, and audio to a certain level. Unfortunately, we bought the system right before HAI came out with the OmniTouch 5.7e touchscreens which hook up straight to your ethernet network. He has a total of 6 5.7 touchscreens around the house, several scene switches, and audio in many rooms. I also have it st up so that when he sets the system to away, it automates the process of pushing his normally daily buttons… wake up, go to work, evening, go to bed, etc. Makes the house look very lived in.

Now it’s my turn…

Just recently, my girlfriend and I put a contract on a brand new house, that is being built as I write this. I don’t have the money my boss has. We spent nearly $15k implementing the system, including all the audio, and someone else doing the install in his house! So, I decided to look at other avenues for automation in our new home. After some research, I decided I would purchase an Elk security system, and couple it with an automation box line the Mi Casa Verde Vera/VeraLite, or the isy-99i. I ended up purchasing the VeraLite, and also a few insteon devices and PLM to communicate with the Vera. After over $500, and several days of tinkering, I came to realize that Insteon really sucks as much as X10. It was completely unreliable, half the time signals didn’t make it through. Even with a phase coupler installed, no signal would go across a phase. I had to have them on the same phase, and pretty close together. I even went around the house and unplugged both Plasma TV’s, and my UPS for my computer. No difference. While Insteon has dual-band capabilities, not all of their devices do. Specifically, find me a non-dimming switch for CFL or LED lights, that is dual-band. Sorry, doesn’t exist unless you buy a scene switch with a 15A relay in it. I was so frustrated, and jealous that my boss’ system works so flawlessly, I decided to abandon my project with Insteon, and set off for HAI land. I know the system well, and they are constantly doing updates that add new features. I returned all the Insteon junk, and sold the VeraLite on ebay.

After some more serious research, mostly to find the right vendor to buy from at the right price, I decided to purchase from http://www.discounthomeautomation.com (DHA). I shopped around on their site before I finally settled on what I would purchase for the system. Keep in mind, it’s currently March 2012, and the house will not be done until July 2012. I’m trying to not go overboard, but slowly collect until move-in day comes.

Here’s what I purchased from DHA:

3 HAI UPB Non-Dimming Wall Switch, 600W $175.56
1 HAI UPB Dimmer Wall Switch, 600W $58.52
1 HAI 8 Relay Module $55.86
1 HAI HLC Powerline Phase Coupler $49.88
1 HAI Extended Range Indoor/Outdoor Temp Sensor $42.56
1 HAI Omni IIe Controller with Enclosure $715.54
1 ELK AC Transformer with Ground, 24VAC 40VA $13.95
1 Interstate Batteries 12V 12AH SLA .187 FASTON $26.27
1 HAI UPB PIM to PC Cable $6.65
1 HAI UPB PIM & Cable $61.18
1 HAI Omni Console $111.72
5 Seco-Larm Enforcer Magnetic Contact $7.30
1 USP ST-1 Siren Horn Strobe $37.17

I also ordered a couple of garage door contacts from another place, and had the garage wired with 2 cat5 runs. One to the front, between the two garage doors, and one that goes where the garage door buttons are. That way I can sense if the doors are open, and shut them if they are open too long. I also plan on installing a simple on/off switch on a zone for turning on and off the auto garage function. The USP ST-1 siren/strobe will be on the wall with the buttons, to alert anyone in the garage that the door is about to close, if it’s been open too long. This uses 3 relays on the 8 relay board. A 4th relay will be used to control the fireplace, and the rest I have no use for yet. It was a $10 difference between the 4 relay board, and the 8 relay board. I figure it’s worth it if I need even one more relay.

Just the other day, I received the vast majority of my items from DHA, in an extremely timely fashion, with fabulous communication from them. Two of the items I ordered (one HAI switch, and the ST-1 siren) were backordered but would ship in 3-5 days. It shipped 3 days later, and should arrive today. Every item was brand new, in unopened HAI packages. Even the HAI system itself was factory sealed, and had the 3.10 firmware on it which has only been out for a few months. Bravo DHA! I highly recommend ordering from this place, and I know I’ll order all my stuff from them in the future. I considered ordering for surveillent.net because their prices are just slightly lower, but there are SO MANY negative reviews about them, that I didn’t want to take a chance. Even on ebay.

After hooking up the HAI system in a temporary place inside the house so I can play with it, program it, and more closely understand how I can use it, I decided to install one non-dimming switch in the kitchen to start testing. It was immediate failure, but I hadn’t yet installed the phase coupler. I decided to plug the PIM into an extension cord and plug it in at various places around the house. Failure again. I was becoming sure that the electrical system in my home was a serious problem. So, I did a bit of research, and looked into purchasing noise filters for certain devices, but it’s stupid to start buying filters without knowing what’s making the noise. There are many reports of people having a cell phone charger that destroyed their X10/Insteon communications, so I needed to test first. I found information on using UpStart software with the PIM plugged into the serial port of the computer. This is why I purchased the serial cable for the PIM. I started, then, by killing the power, and installing the phase coupler, and making sure it worked. Once that was done, I attempted to configure the kitchen light switch, from a plug in the kitchen which I had used the night before without success. Immediately it found the switch, and was able to configure it, communicate with it, and do whatever. I was excited! I started running noise tests, then ran around the house turning on computers, plasma TV’s, plugging in AC adapters, whatever. ZERO noise, VERY high signal. So, I moved the PIM back to the original outlet where the HAI system is. Perfect communication again, and even with all the electronics on. ZERO noise. I reset the PIM, plugged it back into the HAI system, and attempted to configure the kitchen light switch. First time it worked, and configured the switch! It seems that my entire problem was related to the phase coupler, and that UPB is definitely far more robust than Insteon and X10. I plan on hooking up a couple more switches in the house for the outside lights, but I don’t want to go overboard, as I have to remove all this stuff in a few months.

The new house will be pre-wired for a security system, which means all the windows and doors will have sensors, and there will be 3 locations for security pads, and a couple additional runs to other places. For now I just have one console, but I plan on buying 2 more, plus a few more switches, before we ever move in. The problem is, I don’t really know enough about what lights in the house I need switches for!

Additional things I plan on doing with the system:
-Doorbell monitoring and silencing (another relay output)
-Hot tub cabinet temperature monitoring for freeze protection
-X10 module for making use of some of the X10 stuff I have left, like motion sensors
-Garage door control through serial based RFID system
-HVAC control with HAI thermostat
-Carbon Monoxide detection

I’ll be collecting a bit more equipment in the coming months, and will be prepared to install this system in the house shortly after we move in.

Cobra iRadar Review

Posted: June 21, 2011 in Rants & Raves

I’ll admit, I occasionally break the law by speeding. I don’t generally like having a radar detector, but I do like having them for a long road trip. Last year, I bought the Escort 9500ix, and while it was a spectacular device, I thought it was a bit expensive ($500+) for what it could do, and I didn’t like that you have to have a subscription paid for each year for updates to their speed trap database. So, I eventually returned it and didn’t buy another.

This year, I decided to buy another radar, but I decided on a much cheaper one this time around. I purchased the Cobra iRadar after some reading. I bought it understanding that it’s not perfect, and that it has a ton of potential. I haven’t used it a lot, and I already have a lot of complaints. They are all items that can be fixed. Some are simple software bugs in the app. All my tests are done on my iPhone 4, or my iPad, but mostly the iPhone. I’m quite disappointed that there are no specifications for this device, as to EXACTLY what radar bands it is capable of detecting. Their web site just says it will detect “all radar and laser signals”. The only indication of exactly what it can detect, is in the app itself: X, K, Ka, VG-2, POP. Nothing related to laser detection.

I bought the radar and set it up in the parking lot of Best Buy. It paired right up with my phone without a single issue. I already had the app installed before I bought the device, so as soon as I opened the app, everything worked. Setup was literally 90 seconds. As I pulled out of the parking lot, I got my first warning. Right there was a cop with some radar. I also caught a speed trap on my way back to work. I don’t like that the blue light is on when paired with the phone. There needs to be some sort of indication that the detector is communicating with the app. This would be nice for having the app running in the background, and connecting to the radar from a pocket. This makes crowdsourcing work from a pocket.

After getting the device home, and really playing with it and the app, I started to find its problems. I have a simple K band radar gun at home that I used for some of my testing. When I pull the trigger on the gun, it can get speed within milliseconds. The radar takes at least 2 seconds to respond to my radar gun. However, I had it catch a cop using POP on the freeway, before I could see him. So it’s obviously got the capabilities.

My complaints are with the app itself. It’s nice, but far from perfect.

  • When receiving a radar alert, as soon as the signal disappears, so does the alert screen. A quick detection from a distant store disappears so fast that you don’t have time to mark it as false.
  • Even though you mark a location as false, it still makes the same amount of noise the next time it is seen. There’s no option to mute that specific alert. (i.e. a store, or a radar sign in your neighborhood)
  • The mute button on the radar alert screen of the phone, mutes the detector, but will not unmute it. The mute icon also does not reflect that it was touched, and that it has muted the sound. You must press the mute button on the detector to unmute.
  • It would be nice to have an option to only run in background when connected to the detector.
  • When on the map, every time you look at details for something, or leave the map, it turns auto-center-map back on, even if you turn it off. So every time you tap on a speed trap and look at details on one 100 miles away, it will recenter the map to your location when you return to the map.
  • When switching to City mode, the radar says “City, X”. Why the X?
    -ANSWER: This means the detector will only beep once when detecting an X signal. Not sure why that needs to be said, but whatever.
  • A speed trap known to me is on the map, but at a speed of 65mph, the phone didn’t warn me soon enough of the trap. If they had been there and using laser, I would have been caught. Detection should be sooner at higher speed.
  • It would be nice for the map to work in landscape mode
  • It would be nice to be able to browse the map and see traps in locations other than within your current location radius, like on the route for a 2500 mile road trip. I am about to take a trip where a leg of it will not have any data access, and it would be nice for that data to be cached in the app until the next time it gets data back.
  • What happens when I’m driving where I don’t have internet access? Do speed traps that are already downloaded in the app, still detected?
  • Severe lack of documentation. There is nothing out there that explains the features of the app. While many are clear as day, some are not. I haven’t been able to figure out if crowdsourcing is actually implemented and working, or not. I don’t know what the purpose of marking an alert true/false is, even though I know what it’s supposed to be in theory.

UPDATE July 20, 2011

Just got back from a nice long trip through Colorado, Wyoming, Utah, Nevada and California. This radar detector is seriously awesome, though I did notice a couple of problems. I notice that compared to the Escort 9500, it’s not quite as sensitive, and therefore gives more realistic warnings of radar signals. The Escort would alert miles away from even the weakest signal, causing you to spend most of your time turning on and off the cruise control, or just ignoring the detector.

My trip was about 2500 miles, and I abused the speed limit the entire way. The iRadar detected every single cop I saw that was running a trap. And in most all cases, it warned me of the cop before I ever saw him. There was only one time that I saw the cop before he hit me with Laser.

I do have one issue with the detector now. It no longer talks to me to tell me what band it is alerting me to. Sure, I could memorize the sound, but I thought the idea was that the option to turn off voice is available in the app. Doesn’t matter what I toggle the option to, voice does not work the majority of the time. The first time I heard a VG-2 alert, I didn’t know what it was, because the detector didn’t tell me. But close to the end of my trip, one laser signal I got it actually said “laser” just like it’s supposed to. I will be calling Cobra about this issue.

Overall, for the price, I would highly recommend this device. Especially with its soon to come features.

UPDATE: 2-17-2012

Just got back from another road trip with just over 2000 miles. This radar detector continues to exceed my expectations, when out on the open road. It still goes off all the time like any radar detector when in the city, but when on the freeway, this baby excels. Due to it’s weaker detection capabilities, it tends to give fewer false alarms. 80% of the times the detector went off, we saw a cop eventually. In many cases, we were alerted in enough time to drop 15mph off our speed, and watch for another 15-30 seconds before we’d actually see the cop coming from the other detection. Likely about a mile. Not sure why anyone in the world would need more advanced warning than that. With the Escort 9500, it would go off several miles before we’d ever see the cop, and most of the time it would end up being a false alarm for whatever reason. Just because a radar detector can detect signals from farther away, doesn’t necessarily make it a better radar detector. It just means you get alerted 5 miles before you see the cop vs. just one mile.

UPDATE: 12-28-2012

I am still loving this radar detector. I actually just bought one last month for my wife, for her birthday. She loves it too. She really wants me to hard wire it into her car so she doesn’t have the stupid cord hanging down. Anyway…

There have been no updates to the app for a couple months, but honestly the app is now so good that the updates aren’t necessary. I swear, whoever wrote the app must have been learning Objective C as they went, because the initial version of the app was terrible, and today’s version is as if it was written by an experienced programmer. Well thought out, lacking massive bugs, and has tons of features that are actually useful. It even supports the iPhone 5’s taller screen. I love the detection capabilities when you enter an area where a cop has been recently.

My only issue I have noticed lately, and this must be due to the iPhone 5, is that when the detector is on and connected to my phone, it causes my car speakerphone to work improperly. I usually end up at a point where I think I’ve lost a call and can’t hear the other person anymore. They can hear me, but otherwise I hear nothing. If I turn off the detector, this seems to go away. Hard to tell if this is due to changes in iOS 6 or the iPhone 5 hardware itself. My wife has also said that she notices it messes with the bluetooth audio in her car when the detector is on and connected. But, she also has an iPhone 5, so again, hard to tell. I still wouldn’t spent 5 times as much money for a detector whose only additional capability over the iRadar is its ability to learn consistent radar signals based on geolocation, and mute them. I wish the iRadar app would give me the ability to mute radar signals in certain areas. Like places I drive with radar signs that I know the detector is going to go off, and it doesn’t matter whether or not there’s a cop there. Now, it would also be nice if it could mute a specific radar band in a specific location, so that if there is a different radar band in that area, you are alerted to it. Like laser vs. Ka vs. K.

SQL injection is a huge issue. Make sure you protect your sites. It’s easiest to do when first building a project, because other items in your code can affect this method. If you use addslashes() anywhere before inserting a value from form data into the DB, then you will want to stop using that function. This function will also handle html forms that pass data in POST as arrays. For example:

<form method="post">
<input type="text" name="values[0]">
<input type="text" name="values[1]">
<form>

In PHP, that comes out as

$_POST['values'][0]
and
$_POST['values'][1]

Using the mysql_real_escape_string() function that is built into PHP, it’s relatively easy to prepare a single value for entry into a SQL DB. This method makes it easy to process ANY 2 level array (i.e. a POST or GET array with arrays in it). Passing arrays one level deep, will work with this method. It’s easy to add on another level, as you can see:

Use this function:

function procformdata($var)
	{
		foreach($var as $i => $val)
		{
			if (is_array($val))
			{
				foreach($val as $i2 => $val2)
				{
					$val[$i2] = mysql_real_escape_string($val2);
				}
				$var[$i] = $val;
			}
			else
				$var[$i] = mysql_real_escape_string($val);
		}
		return $var;
	}

Then use these lines of code, to check your POST and GET data:

$_POST = procformdata($_POST);
$_GET = procformdata($_GET);

Note that once you have run these methods, the data is ready for insert into a mysql database. If you want to display any of this data, certain characters will be escaped, so you may want to run removeslashes() on the data to display it after being processed by this function.

I’ve been doing a bunch of Google Maps API v3 development lately, and I ran into an issue when loading kml layers onto a map. Tracks and points would work great, but any images were coming back as a 404 error. After some research and log watching I discovered the issue. The images for a kml are stored inside a kmz (zipped kml) file. These images are referenced to via a special script at http://www.google.com/mapsatt or maps.google.com/mapsatt.

I found that the API was trying to call
http://www.example.net/mapsatt?id=http://www.example.net/images/test.kmz&f=files/test.png&#8221;
instead of
http://maps.google.com/mapsatt?id=http://www.example.net/images/test.kmz&f=files/test.png&#8221;

I found this article: http://notes.coldshore.com/google-maps-kmz-overlay-images-missing

I had a few problems with some KML files and some URL’s, so I found another way to do it:

Create an index.php script in a folder called “mapsatt” from the root of your web site. There’s only one line of PHP code necessary:

header(“Location: http://www.google.com/mapsatt?$_SERVER%5BQUERY_STRING%5D&#8221;);

Enjoy

1995 Toyota Tacoma HID retrofit

Posted: January 31, 2011 in Projects

I’ve had my 95 Tacoma for many years, and have been putting a lot of money into it lately to restore it. A couple years ago, I got the whole truck repainted black, and had all body damage fixed, and replaced the bumpers and interior carpet and other random items. I also upgraded the headlights to HID’s, but the headlight housings (standard 7×6 housing) were horrible, and didn’t spread the light the way I wanted it to. They also came with this “projector lens” gimmick inside them, which was worthless.

I found http://www.theretrofitsource.com by complete accident, and fell in love with their products. After a ton of research, I decided to buy their bi-xenon PNP kit (http://www.theretrofitsource.com/product_info.php?products_id=178)with FX-R projectors, since I already had ballasts. This came with projectors, shrouds, 4300k bulbs, and adapters to hook up the D2S bulbs to my existing ballasts.

They started out like this:

I started by cutting open the housings (the glue was a silicone glue, so the oven bake trick would not work), then painting the inside of the housing black.

I then cut a significant portion of the back of the housing off, with a nice level cut

I bought a 4″ sewer pipe cap for a mounting template for the projector:

I cut the end off the cap, sanded it down, then cut a hole in it for the projector, using a cardboard template I had made.

I then mounted the projector inside the template, and checked the fit. I also trimmed the apollo shrouds so that they would fit the projector, and inside the housing. I painted everything flat black again.

Here, you can see what the projector looks like in the housing, before doing the actual mount.

Using some bolts, I mounted the projector to the template.

Final coat of flat black paint (upper housing looks dimpled because I had some paint issues, and had to sand a bit with the dremel)

I then fused the housing and template together with plastic epoxy putty. I also sealed the front glass back to the housing.

Here they are in the truck before putting the grille back on

Here’s the light pattern from the projectors (pre-adjustment):

Here’s the comparison of the light pattern, next to my 2008 Mitsubishi Lancer Evolution with factory HID’s. 25 feet away:

IMO, the cutoff of the Lancer, is better than the FX-R projectors. The cutoff is so hard and defined, rather than being soft and set a much different angle.

I’ve got a few more pics to add. I forgot to take pics of high beams, and of course, the finished product in the daylight. We just got a snowstorm that moved in, and now the truck is dirty as hell!

I plan on doing this same setup on my motorcycle (2008 Honda CBR600RR) in the near future.

I’ve been bashing my head for 10 days now, trying to get answers from apple about an issue with a new Mac mini I purchased. Now, I’m a techie. I come from the PC world. I’m not an idiot, and I’ve been doing this a really long time. I know my technologies, especially when it comes to something as simple as a SATA controller and its speed. As well as how to do the math to convert from bytes to bits and vice versa.

Within the Apple store, when configuring a mac mini, within the “learn more” link in the hard drive section, you come across this quote “All Mac mini models include standard Serial ATA hard drives with data transfers up to 300 megabytes per second” Now, if you’re a geek like me, you know that equals out to be about 2.4 gigabits per second. This is the theoretical limit of SATA II. If you were to look at the maximum of a SATA I controller, you’d see that it’s about 1.5 gigabit per second, or 131 megabytes per second.

Now that we have that out of the way, on to the problem.

I exchanged my 8 days old Mac mini for a brand new Mac mini 2010. In the system profiler, if you look at the SATA controller, in the window below you will see Link Speed, and Negotiated Link Speed. On my mac mini it is 3.0 gigabit link speed, and 1.5 gigabit negotiated link speed. Why? Because the hard drive in the Mac mini is a SATA I hard drive. I even called Hitachi to confirm this, AND Apple engineering has confirmed this. How can they get away with advertising it as something, then giving you something in the range of ‘half’? I’m waiting on a response from Apple about that.

Don’t buy a Mac mini. You’re not getting out of it what you should. And check any Mac you are about to buy, for any discrepancies between the Link Speed and Negotiated Link Speed, except optical CD/DVD drives. Most aren’t capable of those speeds anyway. Likely, I’m going to return this mac. I just know Apple isn’t going to fix it and make it right (replace the hard drive with a SATA II version), but I’m sure they’ll take the computer back and give me my money.Holy hell, and I was trying to give Apple a chance. I didn’t realize they hated me so much.

UPDATE: Apple’s response was “Sorry… you can return it if you’d like, but we can’t replace the hard drive”.