📜 ⬆️ ⬇️

Never “do” what you regret or smart home with CCU.IO

On Habré lately there are many articles about home automation. Some articles with extensive reflections on the topic of smart home, not carrying the payload. Some with a specific implementation on a specific proprietary gland, but they lack something to be installed or run in another house.

I want to present a software platform for home automation based on Node.js, which can be downloaded from all sources and installed right now with almost one click (Windows) or one command (Linux / Debian).



Some will have a quite relevant question: why should I (we) talk about my system?
')
I see with what “half-hearted” solutions live home automation enthusiasts and I want to offer a complete solution for integrated home automation software. From drivers to scripts and visualization. All system components are licensed either by MIT or CC NC BY. What does it mean, for non-commercial use is absolutely free, although the system includes 3 people, a “hobby” -let development. I myself invested in the system for 1 year of development, 2 hours a day (every day, including weekends).

To understand the context, you can read the first three paragraphs of the previous article . This article is a continuation.

Introduction

The presented system is the third iteration of the automation system in my home.

The first was: X10 + HTTP Requests,
second: HomeMatic + PHP / MySQL (you can read about them in my previous post)
and here is the third: HomeMatic + NodeJS / JavaScript.

The development of this system began in January 2013, although active growth began in May 2013 and now 3 developers are working on the system regularly (every day) and there are not enough hands for everything.

Lyrical digression

Can not read
When I was ripe for the next step in writing a web interface for a smart home, I already knew that the future system should be able to in any case:

- it should be easily changeable and supplemented;
- it was desirable not to attract additional software for the design, but to do everything in the browser.

After writing the widgets for the main sensors and actuators, it was necessary to revive them with real data. Searching the appropriate platforms in the forums and google, I came across 3 standing systems sharpened by my current automation system:

1. Jarvis

www.nextex-medienagentur.de/jarvis-v2 - (may fall due to stress).

2. HCS - Home Control Suite (http://hcs.xenorate.com/)


3. Dash UI


Jarvis looks very presentable. The person who wrote this interface is professionally working as a web designer. But after a more detailed study, it turned out that this is PHP + Apache + SQL, and most importantly, the position + configuration of all objects is set statically in the HTML file. And we have already done this: when adding a new sensor, you need to edit the HTML file and then dreary to adjust the position and properties of the object, through CSS or the style property, There are no visual design tools for this system.

Home Control Suite was written by the same person as the basics of my past interface ( http://habrahabr.ru/post/149716/ ). He, apparently, also came to the same conclusions as I did, and for a year he had been working on a new system. Having tested the system, I realized that this is what is needed, although the settings of the widgets were criticizing. Nothing, I decided: JS + PHP + SQL, we have already passed and it will be possible to rewrite or improve the interface to the level I need.

I tested Dash UI too, but it was unpresentable and was on an unknown platform Node.js. At that time, it was developed only for 2 months, which also did not inspire confidence.

Along the way, I found out that the developer of HCS lives in my city. What luck, I decided: here we will work together, the more you can easily meet and discuss everything offline. Although the developer of DashUI lived in a nearby city, it was still 80 km away and you would not meet just like that after work.

Having written to a person with HCS about the desire to meet and that he could not put the source code somewhere on the SVN, I received the answer that I shouldn’t call because You can discuss everything by mail, and there is no more reason to meet. He also let me know that the source code I can post myself, but he does not promise that he will use it. Hmm ...

I wrote to a person with DashUI and immediately received a letter with the answer that it is better to talk everything over the phone, since This topic is not simple. We talked for an hour, then I got the battery.

The plus was also the fact that all source codes initially lay on the gita and it was possible to follow how regularly changes occur.

Well, I decided, thinking about HCS: do not want, do not.

And took up the Dash UI.

A year has passed.

CCU.IO + Dash UI is actively developing a team of 3 people with already 200-300 users. HCS is still developing one and has 10 users on its own (I must admit, I myself then lured 3 of them to Dash UI).

When traveling to an automation conference, the developer of Dash UI volunteered to drop me and the HCS developer to the conference venue. Fortunately, we all were going to it. On the way there and at the conference (we, by the way, made a report there) and on the way back, the person who refused to cooperate with me was forced to listen to our discussions, plans, problems, tasks of users - constantly. After we came back from the conference, he said: “Oh, how I would like to participate in a project like yours. It is a pity that I did not call then ... "


System description


Quote from the documentation:
CCU.IO is a program written in Node.js that serves to automate various home (and not so) hardware.
Using the built-in web server, CCU.IO serves as a platform for visualization and allows displaying events using the Socket.IO library. There are no persistent requests to the server (no-polling), and the server itself says when to update the graphic element. The resource-intensive process of constant requests disappears and thus the reaction time to events decreases. Additionally, CCU.IO acts as a proxy between the visualization and the instruments. No matter how many copies of the visualization are running, the load on the devices is always equally low.

You can connect new equipment through the so-called drivers. At the moment there are drivers for Philips Hue, Sonos, IRTrans, connection to the MySQL database, as well as various web services (Weather, currency, mail, pushover). Some new drivers are in development or are planned for the near future.

Integrated into CCU.IO, the script engine allows you to automate systems using JavaScript. All the features of the Node.JS environment can be used in scripts (for example, access to the disk system, network functions, etc.) You can also use a huge number of ready-made libraries via npm.

CCU.IO is open source software.


The interaction of the components can be represented as follows:


System components:

CCU.IO

1.CCU.IO is the core of the system. The name CCU (Central Control Unit) came from HomeMatic, where CCU is the central controller and gateway for ethernet communication.
At the moment, the kernel is being rewritten to get away from the architecture of HomeMatic, because the system supports other automation systems in its current form, the new one will be called ioBroker.
The kernel is written in NodeJS / JavaScript and can be run on almost any platform for which there are NodeJS binaries. Currently, a high degree of integration is created for the Raspberry PI. It is known for certain that users launched the system on Windows, OSX, QNAP (ARM / Intell) Synology, Cubietrack, BananaPI, Odroid, Ubuntu (x86) and Debian.
CCU.IO is only a link between components. From it, the drivers (adapters) are started with the specified parameters.

GitHub: https://github.com/hobbyquaker/ccu.io/blob/master/doc/README-ru.md

Drivers

2. A driver or adapter is a JavaScript file that runs in a separate NodeJS process and serves one device or service. The following drivers are currently created:
emailfor emailing
pushoverto send messages to mobile clients (http://pushover.net)
mysqlevent logging to database
graphiteforward events to graphite (http://graphite.wikidot.com/screen-shots). Grouping data in imaginable and unimaginable forms and their display in the form of graphs.
icalGoogle and Apple iCloud calendars
geofencyApple support geolocation systems geofency
growlposts on the Apple Growl App
currencyexchange rates from the European Central Bank. (There are EUR-RUB and USD-RUB)
telnettelnet instrument control
pingpings IP devices on the network
lircto control devices and receive commands via infrared (extra hardware required)
irtransIRTrans infrared system support (http://www.irtrans.de/en/)
huePhilipsHUE lamp control
lgtvcontrol LG TVs over the network
denoncontrol Denon receivers
onkyoONKYO receiver control
yamahacontrol YAMAHA receivers
sonosSONOS sound system control
dreamDreamBOX control satellite receivers (http://ru.wikipedia.org/wiki/Dreambox)
owfsOne Wire File System (http://owfs.org/) - 1-Wire Dallas / Maxim Sensor Data Collection
B-control Energy Managerelectricity consumption monitoring www.b-control.com/energiemanagement.html (no description in English)
all3418v2 - ALLNET ALL3418v2 / IP Thermometer LAN / WLANwireless thermometer - www.allnet.de/en/allnet-brand/pr ... r-lanwlan /
homepilotcontrol system automation rademacher.
homematicHomeMatic automation control (built into CCU.IO).
regomonitoring of boilers Junkers TM75, IVT Rego 634
megaDMegaD-328 support.
rpimonitoring of basic parameters (CPU, Mem, Temperature) RaspberryPI. Supports 1-Wire interface and PiFace.
cubiemonitoring of basic parameters (CPU, Mem, Temperature, Battery) Cubietruck.
sayitvoice messages (text2speech or wav) on the system (Linux, Windows, OsX) or android tablet (via Home24 Mediaplayer - play.google.com/store/apps/deta ... ayer & hl = en).
textCommandsplain text interface (Example: What is the temperature at home?)
owmOpenWeatherMap (http://openweathermap.org/) - weather around the world
yrweather from the Norwegian server www.yr.no
dwdofficial warnings of storms in Germany
fritzBoxdisplay caller list for fritzBox
speedportdisplay of callers for speedport
sun_and_timesunset and sunrise times as well as holidays for Germany
muell_stuttgartgarbage collection time in Stuttgart


It’s easy to create your own driver with knowledge of the system for which the adapter is being created. Of course, JavaScript knowledge will make the task much easier.
There is a demo driver with a lot of explanations from which you can understand: how to write your own driver.

Script engine

3. Scenarios of reactions to events (Actually - automation)
The Script Engine also runs in its process as a driver and serves to execute user scripts in JavaScript. All scripts in the ccu.io/scripts folder will be launched. Management is as follows:

//   var swicthID = 79111; //   var actorID = 80187; //    //     on(swicthID, function (obj) { //     setState(actorID, obj.newState.value); }); //  .    79111          80187 on(79111, 80187); 


Here is an example more complicated:
 var postboxTimer = null; var postboxSensorID = 61555; // ID     subscribe(postboxSensorID, function (obj) { //      if (!postboxTimer) { //    30 ,     / postboxTimer = setTimeout(function () { postboxTimer = null; }, 30000); //   setState(postboxStateID, 1 + getState(postboxStateID )); } }); //       CCU.IO setObject(postboxStateID , { Name: "Postbox.State", TypeName: "VARDP" }, function () { setState(postboxStateID , 0); }); 


The description of functions can be taken on git .

For SctiprEngine, a visual scripting system ScriptGUI is written, where all programming takes place visually.

www.youtube.com/watch?v=xeBXTDaidbU&list=PLsNM5ZcvEidhmzZt_mp8cDlAVPXPychU7 - Attention, video in German.



At the moment, the translation is in full swing. This is a snapshot with an incomplete translation, but something has already been translated.

Dash ui

4. Addition Dash UI (Read Dash-URA) is a visualization system for smart home.
Here are examples of interfaces created using DashUI:












At DashUI.ccu.io, you can poke them and look at the speed. I want to note that the display of graphs and tables does not work in offline mode, so do not be surprised if some pages turn out to be empty.

There are even such implementations (in Star Trek style):





There is a video of creating a simple interface from scratch:



Here are some more videos:

www.youtube.com/watch?v=viE5y8YmZo0&list=PLsNM5ZcvEidgGDCFnm23bub3Mj-ZU4Cp4 - Examples
www.youtube.com/watch?v=gS-O5OKjQhk - Voice messages in German

Open the door by NFC tag:



The disadvantages of the add-on is that the interface does not automatically scale to the screen. But on the other hand, you can draw 2 interfaces: for the tablet / desktop and for the phone. As many do.

GitHub: github.com/hobbyquaker/DashUI

MobileUI

5. The MobileUI add-on is currently called Yet another home user interface - yahui. But the name cuts my ear and we will soon rename it to MobileUI.

This interface looks like a list of devices. You can assign each device or room its own pictures or rename. This completes the system configuration.





This add-on (add-on) uses jQuery Mobile and automatically changes, depending on the device where the page is called.



Slimui

6. SlimUI interface - web visualization system on “Vanilla” Javasript for very old browsers and weak devices. No libraries (jQuery or similar) are used. The data is polled by timer (polling), and commands are given via RestAPI (SimpleAPI).

GitHub: github.com/hobbyquaker/SlimUI

SimpleAPI

7. SimpleAPI - Interface based on HTTP-GET requests of the form:

 http://ccu-io-host:ccu.io-port/api/get/950 


where 950 is the index of the variable from CCU.IO.

The answer is given in JSON format or just a value, as text.
Management looks like this:

 http://ccu-io-host:ccu.io-port/api/set/950/?value=1 http://ccu-io-host:ccu.io-port/api/set/-/LEVEL/?value=0.7 


Used to communicate CCU.IO with external programs such as Trigger or Tasker. For example, I use the interface to open the door lock on the NFC tag, via Trigger.
Description of the interface can be taken on git .

CCU.IO-Highcharts

8. Addition of CCU.IO-Highcharts.
Draw graphs using historical data stored by CCU.IO.


GitHub: github.com/hobbyquaker/CCU-IO-Highcharts

Supplement CCU.IO-Eventlist

9. Addition of CCU.IO-Eventlist.
Used to display events recorded by CCU.IO


Graphite

10. Graphite adapter.
Powerful data visualization tool created by another team. Can add graphics and manipulate data. For example, to count: how much time in the last month lamps in the hall were burning.



But I myself do not use it, tk. For normal operation, something is needed more powerful than RaspberryPi, and also because of the terrible lack of time.

This system is quite voluminous and in my opinion requires a separate article on Habré. It is strange that Graphite has not been described by anyone yet.

graphite.wikidot.com/screen-shots
github.com/graphite-project/graphite-web

Real application


Of course, CCU.IO is installed in my home.
Even twice: a working system on Odroid / Linux (it rarely changes and is updated) and a test system on RaspberryPi (reboots and changes several times in the evening)

Systems work in parallel without interfering with each other and provide high availability (redundancy) service.

I personally use the following add-ons and drivers:
- Dash UI for visualization on the tablet and remote control from the phone;
- Highchart for the presentation of graphs of temperature and humidity in the visualization;
- Eventlist to display the history of events on a single sensor, for example, opening / closing the entrance door;
- Script-Engine for generating text messages for pushover, and generally for associating events with actions on these events;
- HomeListener App for voice control from a tablet or phone

- ping to determine the presence of the wife of family members at home. By the IP address of a mobile phone, you can determine whether a person is at home or not;
- pushover for text messages on the phone: “The doorbell rings ”, “The wash is finished” or “The front door has been open for 10 minutes. Need to check.";
- ccu to control the light, roller blinds and heating. Information about temperature and humidity, in each room and on the street, also comes through this driver;
- ical to display scheduled events and birthdays on the tablet screen;
- sonos mainly to indicate the status of the player, since it is more convenient to manage from the native application;
- fritzbox for a list of calls to your home number;
- yahooWeather for weather information;
- lgtv to turn off the TV when leaving the apartment;
- sayit for voice messages on the tablet;
- rpi to control free space on the RaspberryPi.
- textCommands as a connection point for the HomeListener App

But this is not a complete list of services that could be used. Due to the huge amount of time it takes to support and develop CCU.IO, there is no way to play around and implement the system to the fullest.
As they say: shoemaker without shoes :)

In general, I control the system rarely. She just quietly monitors all the events and quietly gives commands for execution: heating, light on the motion sensor, informs you about what is happening at home with messages.

Total


With the help of CCU.IO, you can put together all the components of a smart home and manage them. You can create various visual graphical interfaces or control the system via HTTP calls.
There is even a voice interface integration, though google will then know what they are talking about at home. (We are checking the possibility of using offline recognition)



Links



PS
I was always jealous of the Alizar and the company, scribbling 2 posts per day.
Writing 80 percent of this article took 3 days. Plus 3 weeks for revision, addition and translation of documentation.

When writing an article, the following similar projects were discovered (some were known before that):
- Node-RED - locally installed IFTT (if than that) Node.js project. Disadvantages: no visualization, although a very thoughtful project from IBM engineers.
- SmartVISU - beautiful visualization. Disadvantages: sharpened only for KNX devices and the layout / configuration of widgets only through the configuration text file.
- MajorDoMo - visualization and automation. PHP and polling events.
- OpenHAB - automation server in Java. Disadvantages: rudimentary visualization
- OpenRemote is another Java automation server.
- Freedomotic is a new open source home automation software distributed under the GPL2 license, written in Java (which allows it to run on Linux, Mac or Windows). The main task of the software is to provide enthusiasts with the opportunity to independently create a smart home system by combining home-made equipment or using ready-made solutions of popular architectures. Freedomotic also allows you to integrate your smart home with social networks, Internet services and third-party applications through a developed API.
- Agocontrol - GNU GPL Python Automation
- Ninja Blocks - automation in the cloud
- Domoticz - automation on C #
- The Thing System - Great for automation, but no visualization.
and dozens of other projects.

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


All Articles