Judging by the previous posts, many of you are interested in hand-made automation of your home. I have long collected my thoughts and ideas on the basis of the construction of the first “smart home” and now I want to share my best practices with you.
What we come to and why
So, it is necessary to determine what we are leaving and what we are coming to. Who is interested in "smart home" v1 - can be found in my profile, in posts. In general, and most importantly, we move away from the X10 protocol and arrive at Z-Wave, from Perl to Java, from webcams to more or less normal IP cameras. I will sign in order.
Z-Wave vs. X10
What do all these scary words mean? For the smallest and not familiar with the subject, a little pokapitanyu excerpts from Wikipedia. Let's go - X10: ')
X10 is an international open industry standard used to communicate electronic devices in home automation systems. The X10 standard defines the methods and protocol for transmitting control signals to electronic modules to which household appliances are connected using conventional wiring or wireless channels.
Differs mind and comprehensible ... In general, now takes nothing, except for the price of modules and the ability to install where there is a wiring. And here come the pitfalls, to some of which I ran only during the installation and operation of this protocol:
Let's start with an extremely low transmission rate. Encoded digital data is transmitted using a radio-frequency flash pulse at a frequency of 120 kHz, a duration of 1 ms, and synchronized with the moment when the alternating current passes through a zero value. For one zero crossing, one bit of information is transmitted. The receiver also forms a waiting window near the voltage transition through 0. The window size is 200 µs. The presence of a flash pulse in the window is a logical “1”, the absence is a logical “0”. In general, this means that it takes about 1-2 seconds to submit a command to the module.
Noise immunity. She is extremely small. For example, if neighbor Vasily turns on his electric welding machine as usual - wait for problems
Lack of feedback. She is not. Not at all. It is impossible to know the state, although rumors about mythical pieces of iron are circulating, but I have serious suspicions that they are talking about an even rarer beast - the A10 protocol
The impossibility of passing the signal between the phases. If you have light bulbs hanging on one phase, and the controller is connected to another - prepare the loot.
Of the benefits, perhaps, the relative cheapness and a certain freedom from the wires.
And then he comes on the scene, Z-Wave ! A less lit protocol than X10 or 1-wire, but rapidly gaining in popularity and dropping the price of devices day-to-day.
Z-Wave is a patented wireless communication protocol designed for home automation, in particular for monitoring and controlling residential and commercial sites. The technology uses low-power and miniature radio frequency modules that are embedded in consumer electronics and various devices, such as lighting, heating, access control, entertainment systems and household appliances.
The first and perhaps the most important difference here is that Z-Wave is a wireless protocol. That is, now we are absolutely not tied to anything (except sockets for some devices, perhaps). Almost all devices are powered by batteries and according to the statements, they live on them for years. Some micromodules are powered directly from 220V mains. Also, the undoubted advantage is that it is a mesh network in which each node or device can receive and transmit control signals to other network devices using intermediate neighbors. Mesh is a self-organizing network with routing dependent on external factors — for example, if a barrier occurs between two closest network nodes, the signal will go through other network nodes that are within range. Iron prices today are no longer particularly biting.
Now about the minuses (where do without them). The main and worst minus for me, as a developer of my system, is a closed protocol . Those who wish to obtain the specification will have to roll off 10 kilobaksov . But as it turned out, everything is not so bad. Craftsmen reversed the protocol in the most unable way and wrote an open source implementation called open-zwave . In C ++. There is a binding to a python.
In general, everything is not bad. We go further.
Perl vs. Java
Everything is simple - I began to learn Java, and since writing boring Hello World and classes about managers and their salary, from which I fall asleep on line 10 of the code, I decided to try to do something really serious. Google, books and own brains to help. Of course, I invent a lot of bicycles, but where can I go without them, so I ask the guru not to kick them - I know everything, I will correct ... Honestly! :) About the software - at the end of the post.
Webcams vs. IP cameras
Here, too, everything as a whole should be clear. USB-cameras were unreliable, overheated, the image disappeared. Cable lengths, USB hubs - all, thank God, in the past. Now only wireless IP cameras. By the way, the Chinese have PTZ cameras for a little over $ 60. I don't have one yet, but I plan to order it.
Technology
So, with the protocols, languages ​​have decided. Now we go further. From nettop had to be abandoned due to its poor performance. Now I have a little shaggy desktop on all the same Ubuntu for everything.
I want to note that my goal was to get as far as possible from laying the wires, because the apartment is rented and moving can happen at any time. That is, the system should be as mobile as possible. I will describe the available hardware and how it is all connected:
one desktop
two ip wireless cameras
Two active microphones SHOROH-7
three speakers (2 + 1 are the simplest)
two sound cards (built-in + PCI) (the main factor is the presence of a linear input)
I apologize in advance for the quality of the photos - everything is done on a mobile phone.
Columns are connected to sound cards, two systems to one through a splitter, the rest - directly. Combined by means of PulseAudio into one sink - we arrange, we get sound in the whole apartment.
With MICROPHONE-7 microphones everything is not so easy.
Let's start with the fact that they are active - that is, requiring 12V power supply. You can take it from our power supply.
As an audio cord, use a twisted pair FTP, where one pair goes to the signal and plus, while the rest are twisted into the screen.
Each microphone is connected to the line (!) Input of its card.
With cameras, everything is simple - they live on their own, the backend takes the MJPEG and WAV stream from each one.
Z-Wave devices
For the test, I purchased a controller, a micromodule-dimmer and a leakage sensor. For example, the controller looks like a regular USB flash drive:
And the leak sensor is the most massive:
Micromodule Fibaro:
It connects simply and according to the instructions:
The network has a video about the installation:
A very big plus of this piece of iron is that it does not require batteries for operation, a neutral conductor and an obligatory monostable switch. Works great with bi-stable.
After the first switching on each device must be included in our network - this is done with the help of the controller, which goes into a special mode, and the transfer of the device itself to the inclusion mode in the network. As a rule, everything is in the documentation and will not cause problems.
IRIS-X
The control system is published under the GPLv3 license. Coft is able at the moment:
View in realtime video from cameras
Recognition and synthesis of speech using Google
Z-Wave network discovery, all devices and their management
The interface copied from examples twitter bootstrap :)
Tons of features in the initial stage of implementation
I take this opportunity to actively urge to join the development :) GitHub reference: github.com/Neuronix2/IRIS-X
A couple of screenshots of the interface (the pictures are clickable):
I am pleased to answer all your questions. Thank you for attention.