Home automation in Java
Posted: Sun May 30, 2010 4: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:
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.
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
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 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