Control your window shutters with JavaFX
If you have remote controlled, electronical, window shutters, continue reading. If you don't have them, this article might not be interesting for you?
I have such window shutters and a lot of windows. I don't own a control center that allows me to automatically open and close my shutters every morning and evening. I do it every day manually. Sometimes sooner and sometimes later - depends on the day of the week.
Why I don't own a control center?
Such control centers are expensive and do not offer expected features. Some of my features are controlling via SMS, controlling via Internet, move shutters to a specific position (not only up and down).
I didn't really search for a solution of my "problem" because it was not a problem, it was an everyday task and it was habitual. Since I own a RaspberryPi, I tried to find useful solutions, not only Hello worlds. That's the reason why I tried to control my window shutters via Raspberry Pi.
The first big problem was, that it was not possible to find a sender for my shutters. The frequency was 433,42 MHz, but there were no ready-to-use solutions. It was not my intention to solder my own sender and record and decrypt the signal. So, I decided for the easy way: Connect an existing remote control with my Pi. It makes no difference for the remote control, if you press buttons manually or a Pi does the job.
It was not a big problem to find some cheap 3V relais. The soldering was fun and not rocket science. Here is the result:
My remote control got a new brain. It works with and without connected Pi. I didn't damage it
The only thing I had to do, was programming every receiver with one (or more) channel of my remote control. Because one button should control all window shutters. But that was a task of 5 minutes.
The hardware was ready and the next step was a fancy client application for controlling my Pi. The plan was a simple application that shows one of my windows. The shutter should move like the original. The application should connect to my Pi via my LAN.
I used JVx and vert.x on server-side for the GPIO control, wrote a nice Deskotp application with JavaFX, some transitions and JVx for the communication to my server. And here is the result:
The application moves the shutter like its big brother. One feature is transparency on mouse over, because you wanna know the position if you stop it.
And if you are interested how software and hardware acts together:
The project was really cool because the source code for the whole thing was minimal, the costs were not comparable to a control center from the manufacturer and I have all features I ever wanted.
Interested in the source code?
Server-side, JVx style:
// Application.java
//----------------------------------------------------
public GpioController getController()
{
GpioController gpio = (GpioController)get("controller");
if (gpio == null)
{
gpio = GpioFactory.getInstance();
put("controller", gpio);
}
return gpio;
}
public GpioPinDigitalOutput getDownPin()
{
GpioPinDigitalOutput pin = (GpioPinDigitalOutput)get("downPin");
if (pin == null)
{
pin = getController().provisionDigitalOutputPin(RaspiPin.GPIO_01, "Down",
PinState.LOW);
put("downPin", pin);
}
return pin;
}
//---------------------------------------------
// Session.java
//---------------------------------------------
public void moveDown() throws Exception
{
GpioPinDigitalOutput pin = getDownPin();
pin.high();
Thread.sleep(2000);
pin.low();
}
And my client simply calls:
macon = new MasterConnection(con);
macon.setApplicationName("shutter");
macon.setUserName("user");
macon.setPassword("pwd");
macon.setAliveInterval(-1);
macon.open();
macon.callAction("moveDown");