Smart Home (The Beginning) - Part 2
This is a continuation of the article: Smart Home (The Beginning) - Part 1
In the last article I wrote about what a smart home is and where to start when creating it. Now I will try to describe the technical part: hardware and software. Just in case, I remind my dear reader that this is not HOW to , but a review material, therefore there are most likely no concrete solutions and code inserts for copy paste. There are a lot of technologies and methods for solving the assigned engineering problem and it will not work to describe everything in my articles.
All information is written with emphasis on personal experience, no “sofa” speculation.
Now back to the topic.
As mentioned earlier, the core of the system should be located in some place isolated from the residents, and what, in fact, is this core from a hardware point of view? Of course the server. Yes, the server, not Arduino, not RazBery, not a router with OpenWrt, namely the server. Why? Because productivity, and also because all Arduins and other products are created in order to teach schoolchildren / students in programming microcontrollers and working with peripherals. These devices were not originally designed to deploy a complete turnkey and stable solution. More precisely, no, you can deploy it, but at your own peril and risk. In general, to put it bluntly, this is a constructor for adults, such as Lego Mindstorms, only a little more complicated. In no case do I have anything against these devices, everyone just has their own tasks.
But by the word "server" I mean not a rack like in the Data Center, stuffed with blades, but some small servochka. After all, we need to control the house, and not calculate the protein folding, right?
The server can be a small mini-ITX computer with a dual-core processor such as D525 and 2GB of RAM. This decision will cost approximately $ 200.
This is such a small beautiful solution. If you want to deploy media storage on this server, you can plug in a ~ 3TB external drive via USB.
If the server pledged more money, then you can take an HP microserver, such as this one:
it has the potential for growth, but it might not suit anyone.
The price is about $ 280 for a starter kit (dual-core processor, 2GB of RAM and one SATA drive for 250GB)
. There is no point in putting something bigger and more powerful, because this iron is enough with the head.
If possible, look for hardware with USB 2.0 (even better: USB3).
It will also be a plus if you use an SSD drive as a system disk. This will give a good increase in the core load speed of the smart home. For example, the core of my smart home boots up (with an SSD) no longer than loading a regular household Wi-Fi router - turn it on and use it.
To configure the server, you will temporarily need a keyboard and monitor (to deploy the OS, the rest of the configuration will be done remotely).
We must not forget about the network.
If possible, it is better to lay a twisted pair cable in advance to all stationary network devices (computers, media players, network printers and cameras). For switching, it is better to use switches (switches) with Gigabit Ethernet ports.
To connect to the provider's network, you can use any router with Wi-Fi, but it is better not to connect anything other than the above switch / s to its internal ports.
In general, try not to count on Wi-Fi, especially when it comes to transmitting media stream (video / sound) - there may be delays and failures.
In general, the connection diagram should be approximately as follows:
You connect the cord received from the provider to the WAN port of your router, and connect your switch to the LAN port.
In turn, you connect all other network devices to the switch.
Why is that? In order to prevent a “fall” of the entire network, if, for example, your not-so-well-purchased router suddenly freezes. At the moment of rebooting the router, all devices connected to it will lose connection, and if you watched video from the network storage connected to the router on the media player, then the viewing, as you understand, will be interrupted. Pleasant not enough.
If your house is large, then, perhaps, to fully cover the entire home with a wireless network, signal repeaters will be needed. Do not hope that you buy the most expensive Wi-Fi router and it will “break through all” your reinforced concrete partitions. It’s better to take the router “in an easier way”, and to it a couple / three of repeaters.
I recommend deploying on a server as a Debian Linux system operating system without a graphics system. Why him and not, say, Ubuntu? Well, firstly, Ubuntu is mainly installed by those who need the X-window system, but why do we need graphics on the headless server? Who will look at what? And secondly, Ubuntu, in fact, is Debian, only with all sorts of whistles / frauds that you can deliver yourself (I hope so, because without these skills you can’t fully deploy Smart Home right). But if you are used to something else (for example, the RedHat family, or Slackware), then do what is closer and more understandable to you. In the end, you have to set it all up.
From the software, I think to install Samba correctly (most household players with a network on board can work with this) and NFS (not a Need For Speed game, but a Network File System). NFS will come in handy if you use MacOS or Linux on your computers / players at home. It seems that they even say that NFS loads the processor less than Samba, but personally it seems to me that it is unlikely to create a large load on the scale of the house.
If you have a so-called Smart TVs, you may have to deploy UPnP and DNLA servers, as most smart TVs do not understand either Samba or NFS.
To deploy the DNLA / UPnP bundle, I recommend turning my eyes to the PMS project ( PlayStation3 Media Server), which once grew out of a media server deployed on the platform of a hacked PlayStation3 game console. The project has grown and mutated in UMS (http://www.universalmediaserver.com/). Installation is quite simple, it is better to read the latest installation information on the project website.
I tested PMS and UMS with transcoding - everything worked flawlessly. Even when using the Xbox360 console as a media player (it has a specific profile for working with UPnP): everything worked.
There is another UPnP server: PlexMediaServer(https://plex.tv/), but to be honest, his work with transcoding on Xbox360 could not be verified, because I had already sold the prefix by that time. In general, Plex is very powerful and functional, it may even seem excessively functional to some, but it works on Smart TVs and nobody seems to complain.
I myself do not particularly use UPnP, because my TVs are old, not Smart, and equipped with Dune players that work great with a video / music repository (by Samba) located in the core of a smart home, but just in case, Plex still works and is always happy to serve some android client .
If you like downloading videos from torrents, then Transmission, an application for downloading from torrent trackers, can be put at the core of a smart home. Transmission can work without a graphical system and can be controlled via the web-interface or using Transmission-remote (application for remote control of downloads). Delivered from linux distribution repositories
In addition to the Media component, someone will probably want the smart home to voice something or receive and process voice commands. For example, you say: “Hut, what is the temperature outside?”, And the system answers you with Millar’s voice: “Wow, wow! On the street 25 degrees below zero. Get into my stove, warm your bones. ”
So, given the concept of "Isolated and self-contained smart home" (which was discussed in the first part), all kinds of crafts based on Google Voice or Yandex Voice API services need to be dismissed. Make the system normal, not holodran. Of course, I understand that it is difficult for residents of large regions to imagine the lack of Internet in the house, just as it is difficult to imagine that Google may be unavailable, but ... until August 1945, the Japanese also could not imagine that only one bomb could destroy the whole city. Lizard Squad
Guysshowed the whole world that ideal services do not exist: Sony’s PlayStationNetwork and Microsoft network lay 4 days due to a massive DDos attack, and in some regions on the 5th day they observed the inaccessibility of these services. It is possible that some Blizzard Division will appear and go after Google / Yandex, therefore you do not need to trust online services. Well, or if you still rely on these services, then design your smart home so that, in the event of the destruction of the Global Network, the functionality of your system is not violated.
Whatever happens in the world, your smart home should "... work, work, and work" (from advertising batteries).
The same applies to all services such as Openremote or Fibaro: like, configure your server from anywhere in the world, and it will pick up all the settings and immediately work as you need. But how will you configure the same expensive Fibaro if the service will “lie” under DDos for a month? How do you add a new dimer to your controller? You get to configure it locally. So all these services you just do not need. Do your thing right away and for sure. So that nothing would overshadow your life in the midst of your beautiful home.
Now one more part of the smart home that you might need:
If you will do video surveillance, then I recommend not using analog cameras, but network (IP cameras) with power over Ethernet (PoE). These cameras give a good picture (often HD / FullHD) and it is easier to build an archiving system with them.
In addition to cameras, you may need NVR (Network Video Recorder) - this is such a “box” responsible for receiving and saving images from cameras.
In the matter of organizing NVR, just another plus will be if you build the core of your smart home on a Linux server. All NVR functionality can be deployed directly to it. But if the core is Arduino, Rasbury or similar controllers, then they will not pull the NVR functionality, because there simply will not be enough performance.
For those who haven’t enough imagination to figure out how to implement this, I can suggest the Moment Video Server project ( http://momentvideo.org/ ). This is not an advertisement.
These people make a very sensible and productive video server, incl. and with the NVR function. The system is shareware and you can put on your server a version that supports a limited number of devices.
Installation is simple:
Pull the installation archive:
(if you have a 64-bit OS)
tar -C /opt -xzf moment_14-04-29_linux32.tar.gz
As a result, the following directory will be created: / opt / moment The
configuration is done by editing the moment.conf file .
For more information about the configuration, see the authors website: http://momentvideo.org/doc.ru.html
The server is launched by the command:
By default, in your browser, open http: // ip-server: 8080 / moment /
and you will see the Moment server page.
I played with this thing and still built something of my own.
If you want to do not a NVR, but a motion recording system, then select cameras that support MJPG (aka MotionJPEG), for which this task is solved very simply: installing and correctly configuring the Motion application from the linux distribution repository.
When I was building my video surveillance system, I introduced the concepts of “Operational Archive” and “Long-Term Archive”.
The operational archive contains entries for the current day - this is convenient if you want to quickly look at “what is it and how”, and the long-term archive is an archive with categories by year, month and day. A long-term archive is synchronized with the cloud late at night, and an operational archive is written to disk and to the cloud in real time. An operational archive in the cloud will be needed if intruders penetrate the house and, in addition to values, take out / destroy the core of the smart house.
In the office of the officer you simply go into your cloud and view all the camera records until they are turned off.
Another option: hidden network storage, where the video archives will be synchronized. Most importantly, this vault should be hidden in a reliable cache, so that attackers do not find it.
UPS, of course, should hold not only the core of the smart home, but also the PoE stack of your cameras.
Instead of the conclusion,
Everything described above can be built on the Atom dual-core processor with 4 Gigabytes of RAM, moreover, I built it and use it in my house. Make the core of a smart home with your own hands, without the use of solutions with limited functionality. Most important: a clear plan, a well-posed engineering task and straight arms.
Now it’s all. To the howl, for the very beginning and for understanding the approximate scale of the work, this information should be enough.
Perhaps I will remember something else, and if there is enough information, I will write the next article.
Thank you all for your attention.
Happy holidays, dear readers!Happiness to you and your loved ones, peace to your home!
PS There was no time to read the text very carefully, so if there are glaring typos / typos, let me know and I will correct it.