Home automation in Java

Pop your questions regarding Home automation software here.....

Home automation in Java

Postby korsteed » Sun May 30, 2010 3:27 pm

In this topic you can share information about building a home-automation system in Java.
I will start with sharing some code/information I used in my own project.

For controlling KAKU (Klik-Aan-Klik-Uit) devices, I am using the LM Media LightManager Pro.
I installed the Lightmanager's Lightman studio software and enabled the webserver.
The lightmanager signal can reach my whole house. With the lightmanager, KAKU devices can be controlled
by HTTP.
On my local network I can switch to scenario 1 by going to the address:
http://localname:80/?key=1

So, from Java I can call it with this code:

Code: Select all
String switchKey = "1";// get this from input.
String requestUrl = "http://localhost:80/?key="+switchKey;
try {
  URL url = new URL(requestUrl.toString());
  BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  String inputLine;
  while ((inputLine = in.readLine()) != null) {
     //  System.out.println(inputLine); 
  }
  in.close();
} catch (IOException e) {
  e.printStackTrace();
}



I have wireless IP-camera's from Sitecom.
You can get images from this camera by making a request to a local http-address.
For example:
http://10.0.0.1/img/snapshot.cgi?size=3&quality=1

I build a servlet that works as a proxy for my local network.
So instead of requesting an image from a local address, you can request the image from the
servlet.

Code: Select all
  public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
  {
    response.setContentType("image/jpg");
    OutputStream out = response.getOutputStream();
    String pictureLocation = "http://10.0.0.1/img/snapshot.cgi?size=3&quality=1";
    URL url = new URL(pictureLocation);
    URLConnection uc = url.openConnection();
    InputStream in = uc.getInputStream();
    int c;
    while ((c = in.read()) != -1) {
       out.write(c);
    }   
    in.close();
    out.flush();
  }


I started controlling X10 signals. This worked, but as my powerline-network is divided into 3 parts,
I can only reach 1/3th of my house, so I stopped using X10.

This article describes how you can control X10 from Java:
http://justdevelopment.blogspot.com/201 ... 0_and_Java

Basically they use a COM interface (com4j) to talk to the X10 development api ahscript.dll
korsteed
Starting Member
Starting Member
 
Posts: 29
Joined: January 2010
Location: Vleuten

Re: Home automation in Java

Postby korsteed » Mon Mar 14, 2011 6:57 pm

I have posted some sample code on making a socket connection to a RFX com receiver here:
domoticaforum.eu/viewtopic.php?f=7& ... 652#p47652
korsteed
Starting Member
Starting Member
 
Posts: 29
Joined: January 2010
Location: Vleuten

Re: Home automation in Java

Postby freedomotic » Mon Apr 02, 2012 5:35 pm

Hi, with Freedomotic is quite simple to create a plugin for sending/receiving commands using an ethernet connection.
Take a look at this plugin for an ethernet relay board with an integrated webserver
http://code.google.com/p/freedomotic/wi ... ernetBoard
Freedomotic Open Source Building Automation
http://freedomotic.com
User avatar
freedomotic
Starting Member
Starting Member
 
Posts: 33
Joined: March 2012
Location: Italy


Return to Questions & Discussions Forum

Who is online

Users browsing this forum: No registered users and 1 guest