In this article I will talk about one project that I have been doing for quite some time and which has been available to the public for some time. We are talking about the MajorDoMo (Major Domestic Module) smart home control system, which is the central unit of a set of software and hardware solutions that I, by virtue of my modest possibilities, implement in my household.

But first things first…
')
Use RestrictionsThe project is not a product in any way. Project status - development and research. The project is not quite easy to understand and is intended for home automation enthusiasts. Deep implementation and customization of the project for their own needs will require programming skills and at least a basic understanding of the object-oriented approach to development. The following features can not be fully realized or not thoroughly tested. It is not allowed to use the system in cases when the life or health of people may depend on the reliability of the functioning of the elements of the system.
But let's not talk about the dark :)
ConceptThe project is based on several fundamental principles that determine the direction of development.
Principle one (“conceptual”): smart home is not only (and not so much) “iron”.
In my understanding, the formation of a “smart” environment, which is not limited to sensors and actuators, is much more important. Yes, sensors and actuators should provide comfort and safety, but this is a minimum program. The environment should have internal and be able to use external information resources in order to adequately manage the existing technical base and even help a person in organizing his life.
The second principle (“mundane”): we build the interaction of the system elements on the HTTP protocol.
Firstly, the presence of a network at home is not something “out of the ordinary” - Ethernet / Wi-Fi is easy to deploy, flexible to configure, and, in many cases, it is already available. Secondly, HTTP access is embedded in an increasing number of devices - from specific controllers to network cameras, not to mention the presence of HTTP-API protocols in many applications and services. By the way, this principle does not exclude the integration of the zoo of specific protocols and devices, but only through auxiliary software or hardware controllers. As part of this principle, the inner world of the system is worth mentioning - it runs on a web server and the user interface is a web site, so you can access the control from any device that has a web browser.
The third principle (“flexibility in integration”): the depth of system integration is determined by the user's needs (and the degree of trust in the system).
This means that the role of the system may be different. In one extreme case, the system can be a control center and be responsible for the logic of the functioning of the entire periphery, i.e. process signals and give commands to all “slave” devices. In the other, the system is only part of a distributed network among sensors and controllers, the reliability of which is significantly higher due to the specialization of tasks. In the latter case, the controllers only inform the system of their condition, but do not rely on it in decision making. As practice shows, in a home environment the best results are achieved by a combined solution, and the degree of bias to one or the second extreme is determined by a specific task.
The fourth principle (“easy on the rise”): the system should be easy to install to see and try something.
Installing on a Windows PC is as easy as installing any other application. For a Linux system, it is no more difficult to raise a site on a local web server. There is no need for any “hardware” at all - you can use info-applications and program a reaction to data from the Internet.
But let's digress from the theory and move on to practice :)
OpportunitiesBelow I will list the features that were implemented using MajorDoMo. A description of various use cases is collected on the project site - I believe that this gives the most visual representation of the system.
So…
- In the morning (not earlier than 6 and not later than 11) when it detects the first movement in any of the rooms (except the bedroom), the system tells about the current state (outside temperature, dawn / dusk time) and includes music (random folder added to the “favorites” )
- When opening a garage or entrance gate, the system reports this. Also reminds, if they are not closed (every 15 minutes, but it is easily disconnected if needed)
- The temperature in the heating circuit is constantly monitored - when leaving the nominal range, voice notification is also sent to Skype (for example: “The boiler temperature is 65 degrees Celsius. Attention is above the norm and continues to grow!”)
- The system knows what the temperature on the street and in the rooms of the house
- The system can receive commands via internal chat, via skype, from a smartphone (including voice control)
- The system interface is available on any device in the home network, as well as via the Internet (it is locked with a password). The interface itself is optimized for mobile devices (using jQueryMobile).
- The system interface has access to the image from IP cameras and the system can react to the movement detected by the cameras.
- The system controls individual elements of ambient lighting, turning it on half an hour after sunset and turning it off one hour before dawn
- The availability of devices connected to the home network is being monitored — they can be used to identify problems or determine the presence of someone from the home (by automatically connecting to Wi-Fi gadgets)
- The system periodically scans the Bluetooth range for the presence of new or previously recognized devices (by MAC address) in the radius of action - the presence of people is also determined by these labels
- The smartphone automatically transmits GPS coordinates to the system and the system keeps track of the user's movement, reacting to entry / exit from certain locations (he knows when I drive up to the house and in the future I can open the entrance gate, and when I approach the store, I can remind that the shopping list not empty)
- Through the system interface, you can control the playback of media content from a local server on any of the home computers (control of the VLC player, as well as the XBMC media center)
- The system has an application for keeping records of products and making a shopping list.
Variants of using the system are constantly updated with new scenarios from users. To implement many scenarios, programming is not necessary at all - it is enough to configure the existing modules and the management interface. For some, it is still necessary to write scripts — for internal scripts, the PHP programming language is used, knowing which, of course, is useful, but in many cases it is enough to use simple constructs from the available examples and do it by analogy.
Iron and softwareAs the head unit, an ordinary PC running MS Windows is used, however the system can be installed on a Linux computer - some adaptation is required, but in general, almost everything works the same on both systems right out of the box. The platform uses the Apache web server, MySQL database and, as already mentioned, PHP. Most of the functionality is executed through the web server, but additionally runs the so-called script of the main loop - from responsible for running tasks on timers.
As already mentioned, the system can work without peripheral iron, but, of course, the more sensors and actuators are connected to the system, the more possibilities open to use.
Initially, the basic hardware module for communicating with the outside world was an Arduino controller with an Ethernet shield on board and sensors connected to it. The controller is connected to the home network and its task is to initiate HTTP requests to the central system when the sensor values ​​change. Another version of the controller firmware allowed using it as a relay control device via the embedded web server. Such controllers can be any number. Later a software adapter was made, allowing the use of an Arduino without ethernet, and connected directly to a computer via USB. The schematic of the controller and the source code of the firmware is also available on the project website.
In addition to the Arduino, support for the 1-wire network controller was built into the system. In this case, the system can communicate with the network through the OWFS module, which is cross-platform in itself and is responsible for interacting directly with the hardware.
From the additional peripherals can be noted Bluetooth-adapter, whose task is to scan the MAC-addresses of devices in the air.
About the Ethernet-network, WiFi and setting up access from outside, I will not stop here - this is a separate topic and you can find a lot of information on it.
In general, that's all. Further development of support for the "iron" protocols will be carried out as needed :)
PlansPlans for the sea! :) Firstly, with the increase in the number of people trying the system on themselves, mistakes and wishes come up - which is, in general, good. If possible, these requests will be closed.
Further, the multi-lingualness of the interface will be brought to mind - this is already laid out, but so far the interface is mixed: something in Russian, something in English, and something altogether under interesting pseudonyms like “SCRIPT_DESCRIPTION”.
Many ideas for adding internal info-applications and integration with existing web services (mail, task lists, social networks, etc.)
There are some reserves for the development of the system in the direction of reaction to the patterns of users' behavior, when sequences of events will automatically be allocated and suggested to automate them (if the system “sees” that in the morning, leaving the bedroom, I pass through the corridor and turn on the lights in the bathroom repeats NN times, why not suggest using this sequence — for example, turning on the light automatically, or using this sequence for an additional action — switching on the coffee maker). But this is still the subject of research.
Instead of conclusionThe article came out more review than technical. Perhaps she thought so.
Project website:
smartliving.ruOn the site you can find much more technical information, screenshots, descriptions of built-in functions, code samples for usage scenarios, as well as distributions of the system itself. In addition, the site has a Forum section to discuss details and ideas.
The system is distributed under the MIT license, i.e. practically without any restrictions (including commercial use), but with the obligatory indication of authorship.
The source code of the system is also fully open and available in Google-code:
code.google.com/p/majordomo-slI take this opportunity to invite those interested to collaborate on the project - there are plenty of tasks, enough for everyone :)