Complete the Noolight Smart Home with the help of the Mikrotik

The Noolight Smart Home system is one of the best solutions on the home automation market today. I am an IT engineer, I have experience in the implementation of automation systems at various residential and office infrastructure facilities. I have something to compare with, since I happened to work with various competing systems, such as 1-wire, bechkhoff, zigbee, x1? KNX.
Complete the Noolight Smart Home with the help of the Mikrotik
I’ll clarify that I don’t consider the Noolight system to be the best room automation system. I consider the system optimal in the segment of home and small office automation. The main advantages of the system:
- implementation price 3r3323216.  
- Completeness of the component base
- the cost of maintenance 3r3323216.  
Like any product, the system has weaknesses. These include:
- weak capabilities of the
- accuracy of sensors
- lack of feedback controller - user
Today I would like to talk about how to eliminate the shortcomings of the system on the example of a typical “hygrostat” scenario.
We expect that the “smart home” will maintain an optimal microclimate autonomously. The microclimate of residential premises, first of all, implies such parameters as temperature and humidity of the dwelling. Hygrostats are used to maintain optimal humidity. Typical scenario of the hygrostat: when the humidity in the room rises, the hood automatically turns on. At achievement of optimum humidity the extract is switched off. Thus, the house itself always knows when and what to do to maintain a comfortable humidity, in theory
At first glance, to implement this scenario, it is enough to simply indicate the threshold values ​​of the humidity sensors for hygrostats and forget about the problem. Unfortunately, this is not the case. In household humidity sensors, regularly use a scale of relative humidity, which reflects the equivalent ratio of the mass fraction of water vapor in the air to the maximum possible at a given temperature in percent. We all remember the school thermo-kinetic theory, which links the dew point, temperature, humidity and pressure in one system. This means that the subjective feeling of air humidity for a person in units of measurement will differ depending on such variables as:
- absolute humidity of air
- atmospheric pressure
- The temperature outside
- operation of the microclimate support systems in room 3r32r1616.  
These factors significantly affect the current threshold for the relative humidity for the hygrostat. Therefore, they can not be neglected. For example, here is a graph linking the sensation of humidity with air temperature.

On the one hand, it is possible to set a sufficiently high threshold value of humidity in hygrostats, which will exclude erroneous alarms. This approach will lead to the fact that the hood in the room will turn on with a long delay, and sometimes, when it is hot and dry outside, it may not turn on at all. We want the hood to be turned on as soon as the user turns on the shower mixer or with a minimum delay. This means that the threshold for triggering the humidity sensor should be only a couple percent higher than the current one. But, if we set a low threshold, false alarms of hygrostats appear, for example, because it rained outside, the temperature or pressure changed. In real conditions, no one needs a hygrostat, whose settings have to be changed several times a month.
After thinking about the problem, I found the following solution. In the system of hygrostat add control humidity sensor. The control sensor is placed in a "dry" place. Several times a day, we interrogate the readings of the “dry” sensor and, on the basis of this, we adjust the humidity threshold value for hygrostats.
Noolight controllers, of course, do not have the ability to implement this logic of operation. But you can still solve the problem using the controller's API. For the sake of such a simple task it would be unwise to launch an additional device on the network. Fortunately, I, like any self-respecting IT person, have a Mikrotik router on the local network.
The first idea was to allocate a partition on the router, deploy CentOs, install httpd, php, crontab, write 40 lines of script and get the result.
But the decision was much easier. We make the script using the standard RouterOS tools, set the script in the standard router scheduler. We add a sound notification to the call of the script in order to know each time the Mikrotik router has completed the configuration of the Noolight controller.
I quote 3r3158. Listing [/b] controller customization script, reset_rhsensors.rsc with comments in the code
3r3162. 3r3391. # Variable: by how much% increase the hygrostat threshold value relative to the control sensor 3r3224. : local sensMaxShift 4;
# Variable: the address of the Noolight PR-1132 controller on the local network
: local pr1132addr "???.2";
# Variables: elimination of the errors of the hygrostat sensors relative to the control sensor 3r-3224. : local sens1rhShift -2;
: local sens2rhShift 3;
# Write to the disk an XML file with readings of all sensors of the controller
/tool fetch url = ("http: //". $ pr1132addr. "/sens.xml") mode = http
: local filename;
: local filedata;
# We consider the file from the router disk to the $ filedata variable
: set filename "sens.xml";
: set $ filedata[/file get $filename contents]
# We know that the control sensor is 3rd in the list, so its value is between the tags
and 3r3190.
# Write the value of the control sensor in the integer variable sens3Value
: local lineBegin 0;
: local lineEnd 0;
: local sens3Value "";
: set lineBegin ([:find $filedata "" 0 ]+ 7);
: set lineEnd[:find $filedata "" 0 ];
: set sens3Value[:pick $filedata $lineBegin $lineEnd];
# We calculate the correct threshold value of the hygrostats and write it into the variable hygroValue
: local hygroValue 0;
: set hygroValue ($ sens3Value + $ sensMaxShift);
# For each hygrostat, we specify the threshold value of the humidity sensor taking into account the error of the sensor and form HTTP requests to the API to adjust the threshold values ​​of the hygrostats into variables req? req2
: local req1 ("http: //". $ pr1132addr. "/hygro1.htm?hygsmd=1&hygssns=1&hygsch=21&hyghst=");
: local req2 ("http: //". $ pr1132addr. "/hygro2.htm?hygsmd=1&hygssns=2&hygsch=3&hyghst=");
: set req1 ($ req1. $ hygroValue + $ sens1rhShift);
: set req2 ($ req2. $ hygroValue + $ sens2rhShift);
# We send HTTP requests with handling of possible errors
: do {
/tool fetch url = $ req1 mode = http keep-result = no
} on-error = {: put ("on-error due 302:". $ req1)};
: do {
/tool fetch url = $ req2 mode = http keep-result = no
} on-error = {: put ("on-error due 302:". $ req2)};
# Play a sound to notify that the script has successfully completed (optional)
: for j from = 1 to = 4 step = 1 do = {
: for i from = 2000 to = 50 step = -400 do = {
: beep frequency = $ i length = 11ms;
: delay 11ms;
: for i from = 800 to = 2000 step = 400 do = {
: beep frequency = $ i length = 11ms;
: delay 11ms;

I quote 3r3158. Listing [/b] file with the values ​​of the sensors, sens.xml , on the controller Noolight PR-1132
3r3162. 3r3163. 3r3164.
3r3168. 26.7 r3r3169.
3r3171. 33 3r3172.
3r3174. 0
3r33177. 25.5 r3r3178.
3r33180. 42 3r3181.
3r3183. 0
3r3186. 24.5 r3r3187.
3r3189. 34 3r3190.
3r3192. 0
3r3195. - 3r3196.
3r3198. - 3r33199.

If you looked at the code, you probably noticed that there is a block in the code for eliminating the error of humidity sensors. Alas, if in one place to place all the sensors, we will see that the values ​​of the sensors will diverge to 5%. It is impossible to find out more accurately the value of relative humidity with Noolight sensors. I believe that for domestic purposes such accuracy is sufficient. This error can be forgiven, given the cost of system components.
Of course, a specialist in the industry may have a Homeric argument that full automation should be without crutches, but on a fault-tolerant base, and on a tire like beckhoff or knx. I agree with everything. But at the same time, I see that Noolight provides a toolkit that allows you to solve problems of small automation, reliable flexible means with the cost of ownership tending to zero. Often, it is these solutions that customers expect from us.
It's nice to see that automation and weak AI have long gone beyond the large corporate segment and are available to anyone. This is what life should be in the 21st century.
+ 0 -

Add comment