Results 1 to 9 of 9
  1. #1
    tommekevda is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default Home Automation system

    HI,

    I'm currently in the design phase of my home automation project.
    Figuring out which technologies suit this project best.
    I have an early experience in building an home automation project by controlling RF controlled plugs.
    For this project i build a plain java program that handles the talking to the arduino, which in turn sent the RF commands. On the other side this program served the HTML code for the client side.

    Since this was messy, having my own webserver code was kind of a pain, i want to take another path.
    Therefore i started reading about JSF.
    This seems like the ideal solution client side wise. However, i need to have a continuous running program in the background that's aware of the current state of the house. ex: when i push a button on the wall, the program needs to be aware and therefore it must be running 24/7.
    With my limited knowledge of JSF i'm not sure if that's possible.

    Then i considered JSF in combination with a plain java program, where the plain java program handled the "backend" stuff (communication with the arduino) and a JSF interface to control the plain java program (through RMI?).
    But in the latter case i'm not sure how i can give feedback to the webserver when i push a hardware button on the wall.

    I'd love to get some feedback and insights on this.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Home Automation system

    JSF is not there to solve all your problems, its task is to provide a web frontend for a web application. It has nothing to do with processes communicating with each other, and that is what you are ultimately describing.

    A rather simple way to make any piece of code 'talk' to a webserver is to use webservices, I highly recommend to look into RESTful webservices through the JAX-RS API, for example using the reference implementation called Jersey.

    https://jersey.java.net/

    If that is ultimately going to work for you I can't know since you're not specific about what needs to happen when you provide "feedback" or what happens when your program becomes "aware".
    Last edited by gimbal2; 01-21-2015 at 09:25 AM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    tommekevda is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default Re: Home Automation system

    Hi,

    Thanks for the already provided feedback.
    Let me further explain.

    I have a raspberry pi. this should run tomcat with the JSF frontend. The Pi should also run a continuous running program (lets call it the home automation daemon) that's aware of the current state of the house. i'll come back to this later.
    The Pi is connected to an arduino. This arduino controls the hardware (triggering the lights). The arduino also senses if a light is turned on via a hardware button on the wall.
    The arduino is supposed to communicate this to pi that's running the home automation daemon. Communication is over USB serial.
    Question 1: Can a web service handle this, more specific the continuous background running?
    Question 2: How can the home automation daemon tell the JSF client code to do a refresh if such feedback is received. i suppose to have the client async poll the status? or are there other solutions?

    In essence, i just need to know what's the best java technology to write the interface code with and what's the best java technology to do the heavy continuous background processing and monitoring and how i make them talk to each other
    Last edited by tommekevda; 01-22-2015 at 08:29 AM.

  4. #4
    tommekevda is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default Re: Home Automation system

    This seems to be a hard subject :)

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Home Automation system

    I once did a similar thing by using an Ardiuino Yun; that thingie is big enough to run a small JVM (jamvm); it polls an Atmega 32u4 continuously and it implements a small (home brew) http server; the actual 'view' of it all, runs on any browser that can (wireless) connect to that Arduino Yun. The Java virtual machine can't run JSF, because the core classes are implemented by gnu (the 'classpath' project), which is outdated and full of bugs' I guess your Pi should be able to do the same, as long as you have the communication right between your Pi and your Arduino.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  6. #6
    tommekevda is offline Member
    Join Date
    Mar 2011
    Posts
    5
    Rep Power
    0

    Default Re: Home Automation system

    yeah, the pi should be able to run everything. the issue is that i'm not sure what technology i have to use to make the link between JSF and the feedback from the arduino.
    I was thinking about servlets that are running in background 24/7. i'm just not familiar with the Java EE technologies to make an educated decision.

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Home Automation system

    Well, if I were going to do it, here is how I would start. Go here --> Free Online Version of Core Servlets and JavaServer Pages (Second Edition) in PDF to learn about Java EE and interacting with web servers (assuming you have no experience).

    Then you can try programming an Arduino with a similar http service which Jos suggested. Of course, you don't have to use http. You could just program the Arduino to accept TCP or IP packets or even low level ethernet frames. For low level protocols, the appropriate drivers and Java API must be found or written to allow such communications. Writing such drivers and the supporting API would be a challenge.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Home Automation system

    I didn't use JEE; compared to that Arduino Yun, it is bloated technology; I wrote my own small http server for the purpose and stole^H^H^H^H^Hborrowed most ideas from this code: JLHTTP - Java Lightweight HTTP Server (Web Server) and from the (largely undocumented) http server that is silently included in the JSE distribution (since version 1.6). The first server contains a few bugs and inconvenient design decisions (they're easy to fix), while the second server is still too large for the Arduino Yun. That's why I wrote my own server. The Linux part of the Yun polls the AtMega part frequently and can 'publish' the result to clients, running a simple browser (html stuff and some Javascript). I read that the Pi carries quite a bit more RAM, so JEE could be another possibility ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Home Automation system

    Quote Originally Posted by tommekevda View Post
    the issue is that i'm not sure what technology i have to use to make the link between JSF and the feedback from the arduino.
    The issue is that you hardly know anything about JSF, so you are making all the wrong assumptions. I can't really blame you because available information about the framework is rather poor and all (decent) books are rather expensive.

    I'm going to make your life easier: you don't need JSF - at all. There are dozens of other web frameworks out there that are easier to learn and can do more with less. But before you think about using any of them, experiment with servlets & JSPs as Jim already suggested and get a feel for Java web development in general. Maybe that will even already be enough for your particular purposes.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Portal web service for home automation with JSF
    By piwi in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 06-14-2013, 10:06 PM
  2. OLE Automation with Excel
    By techmo in forum SWT / JFace
    Replies: 0
    Last Post: 03-04-2010, 07:50 AM
  3. Make money from home, Home Typing Data Entry Partnerships
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 05:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •