Could JavaScript Standardize the Smart Home Ecosystem?

Future Home Run on JavaScriptWhile browsing the web today I stumbled across an article from CNN titled “The scattered, futuristic world of home automation” where the author, Heather Kelly, talks about the exciting world of home smart devices as seen at the 2013 Consumer Electronics Expo in Las Vegas.

She brought up a good question, how does something as low-tech as a light connect to your smartphone? How might it get to the stage where it can talk to other devices? She states that, due to the excitement to get to market, many of these devices don’t play well with others. I found this comment a bit disturbing because she is right. Not only in the home tech department, but across the entire software ecosystem. Standards always seems to fall behind when it comes to the first-to-market rat race. “Who cares about standards when our product works and is cool!”

JavaScript, a possible solution

Could JavaScript hold the answer to unifying the devices (mobile and fixed) and bring the smart home into reality? Think about it. JavaScript is rather light and using data representation like JSON you could easily pass text only data between devices. Given a standard format, messages or objects could be exchanged, parsed and executed on limited memory devices. A typical JSON message may only be on the order of a few kilobytes depending on the complexity of the device and its available features.

For instance, for the door could tell the lights to turn on with a simple message generated when the key was entered into the door…

{ 
	"Device": {
		"Source": [{ "Name":"Door" , "DeviceID":"e387sf1098-2" }],
		"Target": [{ "Target":"Light" , "DeviceID":"h87w4741970-1" }],
		"Actions": [{ "Action":"ON" , "Date":"2013-01-14 11:21:08" }] 
	}
}

This type of notice might be simply pushed to the lights (who are listening and responding to messages with them specified as “target”). They would then run code to turn their light on and then dispose of the request.

How it might work and its advantages

From this object it could see some basic properties like the devices name, maybe some network data like its IPv6 address and a set of key value pairs that tell the lights to turn on. Dumb devices would have simple properties while the home stereo may have many more where only other devices would respond to the data it needs to. Perhaps each device has a framework/library like jQuery included to help programmers streamline further.

Taking it another step, apps could be built for smartphones which feature web apps, or even be accessed through a desktop browser, to send messages to devices back at home. Perhaps this involves a standard home routing service that listens for requests off the Internet and directs JSON messages to the appropriate device based on a device ID specified in the destination information.

In addition to all that, the reflective abilities of JavaScript can also see devices receive JSON, parse it into objects, reflect on those objects to see what a new device introduced to the home can do and act accordingly.

JavaScript is here and already available

Given that many developers today are also fully trained and aware of what JavaScript can do, there is already a built in group of skilled professionals who can begin development of this stuff right away. They can begin to build all the home functionality quickly and easily into their all-in-one home control apps and create options for plugging in devices easily.

I think JavaScript may hold the answer to being able to at least communicate the information and intentions behind several devices in the home. Now all we need for the manufacturers to do is get on board with it and start working on a global device standard.

Thanks for reading! :)

About The Author

Martyr2 is the founder of the Coders Lexicon and author of the new ebook "The Programmers Idea Book". He has been a programmer for over 16 years. He works for a hot application development company in Vancouver Canada which service some of the biggest telecoms in the world. He has won numerous awards for his mentoring in software development and contributes regularly to several communities around the web. He is an expert in numerous languages including .NET, PHP, C/C++, Java and more.