My smart home on .NET, version 2.0

    Good evening!

    I bring to your attention a project that I have been working on for the past year and a half. This is a software product (to be precise, .NET Windows Service), with the help of which you can organize the control center of a "smart home" on your computer. Although this is just my hobby (my main job is a .NET web developer), many people to whom I showed my project highly appreciated it. I am writing this article to try to interest you.


    If you type in Google "smart home", you can see a bunch of sites with suggestions to "install it on a turn-key basis". And although these solutions often look futuristic, they almost always solve problems sucked from the finger. Moreover, in most cases, the functionality of such smart homes comes down to remote control of devices (for example, from a tablet).

    In my opinion, a “smart home” is what independently makes decisions on managing home devices based on information coming from outside (for example, from sensors) and pre-configured rules. In addition, I believe that a smart home should interact not only with devices, but also with Internet services (in principle, in recent years, almost everyone seems to have begun to think so).

    It all started a couple of years ago with an articleon a habra about the Android application on {x} . It allows you to hang certain logic on various events in the phone. For example, it can send a text message to his wife when you leave work. “Automate your life” is written on their website. “This is the thing that I always dreamed of!” I thought then. “But I want this for my home, not for the phone.”

    Then there was almost a year of experimentation and programming, as a result of which the first version of the application appeared . There were many shortcomings and almost no user interface, but, most importantly, she knew the same thing as on {x} - managing the house according to scripts. Of iron, only nooLite power units and the D-Link DCS-932L IP camera were supported.


    Last week I finished work on the second version of the application . In the new version, the system internals were greatly redesigned and the infrastructure for the user interface appeared. Also, several modules were written that users could use “out of the box” in everyday life: “alarm planner” and “weather forecast”.

    Compared with the first version, the development took less time (about half a year), but the amount of work done was much larger. This is partly due to the fact that, impressed by the article from the blog of John Rezig, I organized a three-month “marathon” with daily code writing.


    The system consists of a “core” and modules (plugins). In fact, the kernel contains only the mechanism for connecting modules and the infrastructure for them (so that they can describe their API and events, as well as use the API and subscribe to each other's events). Also in the kernel is basic functionality like logging and access to the system database.

    All other functionality is implemented in plugins. Even things like scripts and the web interface are just plugins (if you turn them off, the system will continue to work fine, although some of its features will disappear). Technically, plugins are compiled DLLs written in C # or another .NET language.

    Script Management

    Scripted house management is the main purpose of the system. Scripts are small programs that control home devices and interact with Internet services. Scripts are written in JavaScript ( do you still not like JavaScript? ) Through a web interface and run on the server side. Inside the scripts, an API for managing the home is available, which can be extended with plugins.


    The system can be configured to automatically run scripts when certain events occur. An event is a sensor triggering, a timer signal, pressing a button, or, for example, receiving a message on Twitter. New events, like new API commands, can be added using plugins.


    Web Based Management

    There was almost no interface in the first version. Needless to say, this made the system virtually inaccessible to most people? Interface development was the main task of the second version of the system.

    The web interface of the system is a modular one-page application based on backbone.js and marionette.js , the modules are loaded via require.js . For layout, Bootstrap is used , thanks to which everything looks neat and correctly displayed on small screens of mobile devices.


    Plugins can describe their own UI as js / css files located in DLL resources. When a plug-in is installed into the system, its UI is automatically integrated into the home management web interface (a new section is added). For example, this is what the weather forecast plugin looks like.



    In my opinion, one of the features of my project that distinguishes it from other similar systems is the availability of detailed documentation in Russian. See for yourself .
    It took a lot of time and effort to write it (almost 3 months). It was very difficult not to let yourself program new functionality until the documentation for the finished one was written. But writing documentation also had a positive side effect. I had to look at the project from the side of its user, due to which a large number of shortcomings were identified and fixed.
    Another side effect - while working on a project, I learned new things about .NET and web development. By reading the documentation, you may also learn something new.

    Instead of a conclusion

    I think a smart home should automate people's routine tasks. But each person has his own habits and tasks that he would like to automate (as well as various “hardware”). If you realize the Wishlist of all people, you get a cumbersome inconvenient system in which each specific person will not need 90% of the functionality. In addition, it cannot be implemented without a large team of programmers in a short time. Instead of a ready-made giant system, I wanted to make a tool with which you can build your own small home automation system. Something like a designer, to which you can connect, for example, your own devices on Arduino and at the same time not be involved in the independent implementation of the infrastructure and general functionality.

    Try to install the applicationand write your own plugins (it's very simple ). Write about errors and send pull requests . Add to our VKontakte group to keep abreast of project news. I will be very pleased if you like it!

    Also popular now: