📜 ⬆️ ⬇️

Smart home (the very beginning) - Part 2

image
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, let me remind the dear reader that this is not a HOW to , but an overview material, so there will most likely not be any specific solutions and code-inserts for copy-paste. There are a lot of technologies and methods for solving the engineering problem and it’s impossible to describe everything in my articles.

All information is written with an emphasis on personal experience, no "sofa" conjectures.

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, actually, is this core from the hardware point of view? Of course the server. Yes, yes, the server is not Arduino, not RazBury, not a router with OpenWrt, namely a server. Why? Because productivity, and also because all Arduins and so forth products are created to train pupils / students in programming of microcontrollers and work with the periphery. These devices are not originally designed to deploy a complete ready-made and stable solution. More precisely, no, you can deploy, but at your own peril and risk. In general, if I’d put it quite rudely, then this is a constructor for adults, such as Lego Mindstorms, only slightly more complicated. In no case do I have anything against these devices, just everyone has their own tasks. I do not know how anyone, but personally I would not have entrusted the control of the gas boiler to the designer Lego.

But by the word “server” I mean not a rack like in a DataCenter, stuffed with blades, but some small server. We need to control the house, and not to calculate the coagulation of proteins, right?

The server may be a small mini-ITX computer with a dual-core processor type D525 and 2GB of RAM. This solution costs about $ 200.
image
This is such a small beautiful decision. If you want to deploy media storage on this server, then you can plug in an external disk with a volume of ~ 3TB via USB.

If there is more money under the server, then you can take an HP microserver, like this:
image
www.citilink.ru/catalog/computers_and_notebooks/servers_and_net_equipments/servers/753329
He has the potential to grow, but someone may not be satisfied with the dimensions.
Price about $ 280 for a starter kit (dual-core processor, 2GB of RAM and one SATA disk on 250GB)

There is no sense to put something more and more powerful. 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 the system disk. This will give a good increase in the speed of loading the core of a smart home. For example, the core of my smart home is loaded (with an SSD) for no longer than loading a regular household Wi-Fi router - turned it on and use it.

To configure the server, a keyboard and a monitor will be needed temporarily (to deploy the OS, the rest of the settings will be made remotely).

We must not forget about the network.
As far as possible, up to all fixed network devices (computers, media players, network printers and cameras) it is better to lay a twisted pair in advance. 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’s better not to connect anything to the internal ports except the above switch / -s.

In general, try not to count on Wi-Fi, especially when it comes to transferring media data (video / sound) - there may be delays and failures.

In general, the connection scheme should be approximately as follows:
The cord received from the provider, you connect 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? To eliminate the "fall" of the entire network, if, for example, your not quite successfully purchased router suddenly hangs. When the router is restarted, 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, as you understand, the video will be interrupted. Enough is not enough.

If your house is large, then it is possible that signal repeaters will be needed to fully cover the wireless network of the entire dwelling. Do not expect that you will buy the most expensive Wi-Fi router and it will “break all” your reinforced concrete partitions. It is better to take the router "easier", and to him a couple / three repeaters.

Software

I recommend that the server be deployed as a Debian Linux system operating system without a graphics system. Why him, and not, say, Ubuntu? Well, first of all, Ubuntu is mainly set up by those who need the X-window system, and why should we have a headline-based graphics server? Who and what will be looking at? And secondly, Ubuntu, in fact, is Debian, only with all sorts of whistles / perdefies that you can deliver yourself (I hope so, because without these skills you can’t completely deploy Smart Home right). But if you are used to something else (for example, the RedHat family, or Slackware), then do something that is closer and clearer to you. In the end, you all set it 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 Need Need Speed, but Network File System). NFS is useful to you if you use MacOS or Linux at home on your computers / players. They even seem to say that NFS loads the processor less than Samba, but personally it seems to me that it would hardly be possible to create a large load on the scale of a house.

If you have a so-called. Smart TVs, you may have to deploy UPnP and DNLA servers, because most smart TVs do not understand Samba or NFS.

To deploy the DNLA / UPnP bundle, I recommend turning your attention to the PMS ( PlayStation3 Media Server ) project, which once grew out of a media server deployed on the PlayStation3 game cracked platform. 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 checked PMS and UMS with transcoding - everything worked without complaints. Even when used as a media player Xbox360 console (it has a specific profile of work with UPnP): everything worked.

There is one more UPnP server: PlexMediaServer (https://plex.tv/), but, to be honest, his work with transcoding on the Xbox360 could not be verified, since I had already sold the prefix. In general, the Plex is very powerful and functional, perhaps even to some, it will seem excessively functional, but it works on Smart-TVs and no one seems to complain.

I myself do not use UPnP, because My TVs are old, not Smart, and equipped with Dune players that work great with a video / music storage (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 to download videos from torrents, then you can put Transmission, an application for downloading from torrent trackers, onto the core of a smart home. Transmission can work without a graphic system and is controlled via a web-interface or using a Transmission-remote (application for remote download control). It is installed from the repositories of linux distributions.

In addition to the Media components, someone will certainly want the smart home to be voiced by something or accept and process voice commands. For example, you say: “Hut, what is the temperature on the street?”, And the system answers you with Millar’s ​​voice: “Uhhhhhhh! On the street 25 degrees below zero. Get me into the stove, warm your bones. "
image

So, given the concept of "Isolated and self-sufficient smart home" (which was discussed in the first part), all sorts of crafts based on Google Voice services or Yandex Voice API should be dismissed. Make the system in a normal, non-hungry manner. Of course, I understand that it’s hard to imagine the absence of the Internet in a house for residents of large regions, nor is it hard to imagine that Google may be unavailable, but ... until August 1945, the Japanese also couldn’t imagine that only one bomb could destroy whole city

The guys from Lizard Squad showed the world that there are no perfect services: PlayStationNetwork by Sony and the Microsoft network lay for 4 days due to a massive DDos attack, and in some regions they were unavailable on the 5th day. It is possible that there will be some Blizzard Division and Google / Yandex, because you do not need to trust online services. Well, or if you still count 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 impaired.

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: type, 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 set up the same expensive Fibaro if the service will lie under DDos for a whole month? How do you add a new dimer to your controller? You use to configure it locally. So all these services you just do not need. Do yours, immediately and for sure. So that nothing darkens your life in the midst of your beautiful home.

Now another part of the smart home that you may need:

CCTV

If you are going to do video surveillance, I recommend using not 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 a NVR (Network Video Recorder) - this is such a “box” that is responsible for receiving and saving images from cameras.

In the question of organizing the NVR, just one more plus will be if you build the core of your smart home on a Linux server. All NVR functionality can be deployed right on it. But if the core is Arduino, Rasberi or similar controllers, then they will not pull the NVR functionality, because there simply isn’t enough performance.

Those who lacked the imagination to figure out how to implement it, I can suggest the project “Moment Video Server” ( http://momentvideo.org/ ). This is not an advertisement.

These people make a very intelligent and productive video server, incl. and with 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 down the installation archive:
wget http://momentvideo.org/dist/moment_14-04-29_linux32.tar.gz 

or
 wget http://momentvideo.org/dist/moment_14-04-29_linux64.tar.gz 
(if you have a 64-bit OS)
Unpack:
 tar -C /opt -xzf moment_14-04-29_linux32.tar.gz 

As a result, a directory will be created: / opt / moment
The configuration is done by editing the file moment.conf
Read more about the settings on the authors site: http://momentvideo.org/doc.ru.html

The server is started by the command:
 /opt/moment/bin/moment 


By default, in the browser open http: // ip-server: 8080 / moment /
and see the Moment server page.
I played with this thing and still built something of my own.

If you want to make not a NVR, but a motion recording system, then choose cameras that support MJPG (aka MotionJPEG), this task is very easy for them: by installing and properly configuring the Motion application from the linux distribution kits repository.

When I built my video surveillance system, I introduced the concepts of “Operational archive” and “Long-term archive”.

The online archive contains records for the current day - this is convenient if you want to quickly look at what is there and how, and the long-term archive is an archive with categories by year, month and day. The long-term archive is synchronized with the cloud in the dead of night, and the real-time archive is written to disk and to the cloud in real time. Operational archive in the cloud will be needed if the attackers penetrate the house and in addition to the values ​​will carry / destroy the core of the smart home.

In the office of the security officer, you simply go to your cloud and view all the recordings of the cameras until they are turned off.

Another option: hidden network storage, which will be synchronized video-archives. The most important thing is that this repository is hidden in a safe cache, so that attackers do not find it.

UPS, of course, must hold not only the core of the smart home, but also the PoE system of your cameras.

Instead of conclusion

All of the above can be built on a dual-core Atom processor with 4 GB of RAM, moreover, I built it and use it in my house. Make the core of a smart home with your own hands, without using solutions with limited functionality. The most important thing: a clear plan, competently set engineering task and direct hands.
image

Now that's it. At first glance, for the very beginning and for the realization of the approximate scope of work, this information should suffice.

Maybe I will remember something else, and if there is enough information, I will write the following article.

Thank you all for your attention.
Happy holidays to you, dear readers! Happiness to you and your loved ones, peace to your home!

image

PS There was no time to read the text very carefully, so if there are blatant typing errors / misprints, report it and I will correct it.

Source: https://habr.com/ru/post/247105/


All Articles