Smart home with Xiaomi on the example of a bath

There are quite a lot of reviews and videos on the Internet about building smart homes. There is an opinion that all this is quite expensive and troublesome to organize, that is, in general, the lot of geeks. But progress does not stand still. Devices are becoming cheaper, more functional, and design and installation are quite simple. However, in general, the reviews focus on 1-2 use cases, almost without covering the nuances and without creating a coherent picture. Therefore, in this article, I want to review the completed project, demonstrate use cases and pitfalls encountered in building a smart home using Xiaomi devices using a sauna as an example. The described ideas with slight variations can be applied in the automation of an apartment.

Smart home with Xiaomi on the example of a bath

Background or why all this is needed

First, a little background so that the context is clear. At the beginning of autumn 2018, the finishing of the sauna was completed and it was put into operation. The bath is an autonomous capital building with year-round heating and water supply.

Smart home with Xiaomi on the example of a bath
For obvious reasons, no one permanently lives in the bathhouse and does not control the condition of the premises. As much as I would like, but visiting the bath is also not a very frequent event. Accordingly, thoughts about creating a “smart” bath were present from the very beginning of the project. First of all, for the sake of safety (fire, flood, access control). For example, turning off the heating at -35 degrees outside (I live in Novosibirsk) is a very dangerous situation. However, unlike the main house, I did not think over the bath automation project from the very beginning and did not make additional wiring to the right places. On the other hand, the Internet was connected to the bathhouse, and video surveillance is being conducted from the other two buildings (you can assess what is happening visually).

Returning from a business trip in November 2019, in the evening I went to the bathhouse, opened the front door and was shocked by what I saw. From the darkness, the LEDs of the WiFi point flashed to me, and a stream of water gushed on my feet. That is, there was a flood, while the electricity was not turned off. The water in the bath is organized with the help of its own well, a submersible pump and automation that controls the process. As it turned out later, one of the fittings in the junction in the toilet was torn off and all the rooms were flooded. I never found out why the automation took pity and still turned off, but it managed to pump 15 cm of water per 30 squares. It was -14 degrees outside that day. The warm floor coped, continuing to keep the temperature in the room at the proper level, but there was 100% humidity. It was impossible to procrastinate further about the organization of a smart home - you need to start doing it.

Equipment selection

During the construction of the main house, I gained experience with devices Eldes (corresponding posting has been created). Part of the automation is done on Raspberry PI. Another part - on devices Xiaomi Aqara. The option with Raspberry PI was the most attractive to me and initially I considered it for the bath. But, unfortunately, it requires much more effort to organize. It's still not a plug-and-play device - starting with exercises with hardware and ending with writing software for your own needs. For certain reasons MajorDoMo did not suit. Crossing a Raspberry PI, a ZigBee Adapter (to take advantage of Xiaomi's wireless sensors), and an Apple HomeKit required learning (and the Apple HomeKit interface isn't particularly exciting at the moment). There was little time (I didn’t want a repetition of the situation), and there was no wiring for each necessary point, so I decided to do everything on Xiaomi devices.

The main device in such a situation is the hub. In the case of Xiaomi, there are two hub options: Xiaomi Mi Smart Home Gateway 2 and Xiaomi Aqara Gateway. The latter is about twice as expensive, more suitable for the local market and able to integrate devices into Apple HomeKit. However, if you install the Aqara Home application and select the “Russia” region, then at the time of writing these lines, only 13 different devices (switches, sockets, sensors) will be available. If you install the Xiaomi Home application, select the “China Mainland” region, then hundreds of devices will be available for connection. At the same time, if you have chosen the region “China Mainland”, you will not be able to connect a European outlet and vice versa. Selecting the “China Mainland” region within the Aqara Home application does not provide the completeness of devices that is present within Xiaomi Home with the same region. Fearing incompatibility, I decided to stop at the Xiaomi Mi Smart Home Gateway 2 hub. The issue price is about 2000 rubles. By the way, the hub itself acts as a lamp - this can be taken into account during installation.

Smart home with Xiaomi on the example of a bath
A separate interesting question is how long this will all work. It's not even about sensors and batteries in them, but about synchronization and data storage in the cloud. The account is currently free. All information is stored on Xiaomi servers. If tomorrow the guys decide that users from Russia should not store data in the “China Mainland” region or Roskomnadzor bans their servers for some reason, then the whole smart home risks turning into a pumpkin. I decided for myself that in this case the sensors will remain, and the hub will be replaced with a Raspberri PI + ZigBee Adapter.

Leak control and prevention

The first and most important automation scenario was a natural continuation of the problem that arose - in the event of a leak, you need to turn off the water supply, that is, the pump, and send a notification about the problem to your phone. There were two potentially dangerous leaks.

In addition to the hub, this scenario required two flood sensors and a wall-mounted smart plug. The price of the leakage sensor is approximately 1400 rubles. The price of a smart socket for wall mounting is approximately 1700 rubles. Leak sensors are autonomous, battery-operated. The manufacturer claims that one battery will last for 2 years.

Smart home with Xiaomi on the example of a bath
The installation of a smart socket was a little more complicated because Chinese sockets require square sockets, which are not sold in our regular stores (but can be brought to order). Drilling square holes is a lot of fun. Plus, in a good way you need an adapter, although there is also an outlet for a European plug. The Aqara version for the local market does not currently have a wall-mounted outlet, which ties us to the “China Mainland” region. Alternatively, it was possible to install a regular socket, plug a smart socket with a plug from Xiaomi into it, but this would require two additional adapters. Another alternative is a relay. But I settled on a wall-mounted outlet.

Smart home with Xiaomi on the example of a bath
A socket and a sensor have been added to the Xiaomi Home app. Next, the scenario “in case of a leak” is written for two actions: turn off the outlet and send an alert.

Smart home with Xiaomi on the example of a bath
The first leak sensor was installed next to the pump (and, in fact, next to the hub). For the test, water was poured into a small plate, and the sensor was lowered into it. I performed all the action directly at the sensor installation site in order to bring the situation as close to reality as possible. The test was passed successfully: the socket turned off, a notification came to the phone, plus the hub blinked in emergency mode.

The second leakage sensor was planned to be installed in the toilet next to the pipe junction. But with its installation, nuances arose - the hub did not see the sensor, although the distance was small. This is due to the configuration of the premises.

Smart home with Xiaomi on the example of a bath
There was a steam room between the installation site of the hub (rest room) and the installation site of the second leakage sensor (toilet). The steam room, in the best traditions, is sewn into a circle with foil, creating problems with the passage of the signal.

The manufacturer claims that the devices are capable of forming a mesh network, that is, one device can transmit data to the hub through another device. Somewhere I came across information that only devices connected to the network (and not on batteries) can act as such transmitters in a mesh network. However, it was enough for me to install a temperature sensor in the corner of the washing room so that the signal from the leakage sensor stopped disappearing. Maybe this is a coincidence, because further in the washing room under the ceiling a relay was mounted to control street light (perhaps it acts as a transmitter in the mesh network). However, the problem with the loss of signal from the leakage sensor in the toilet has been resolved. Additionally, you can check the connection of the device with the hub by clicking on the sensor in the center. If all is well, then the relevant information will be heard from the hub in pure Chinese (in the case of the Aqara hub, communication will be in pleasant English).

Checking the disconnection followed by turning on the electricity using the machine showed that the smart socket goes into the off state. In order for it to turn on when electricity appears, there is a corresponding setting:

Smart home with Xiaomi on the example of a bath
An additional sign of the flooding of the premises was an increase in humidity to 100%. The control of this feature is discussed in the next section.

Smoke and temperature control

The bath is a fire hazardous room, so the next scenario was to determine the signs of a fire.

For this scenario, two temperature (and humidity) sensors and a smoke sensor were needed. The price of the temperature sensor is about 1000 rubles. The smoke detector costs about 2000 rubles. In the Aqara version for the local region, there is currently no smoke sensor, which again ties us to the “China Mainland” region.

The smoke detector was mounted on the ceiling of the corridor to the washing room (in fact, not far from the stove and the exit from the steam room). Next, a device was added in the Xiaomi Home application and a scenario “in case of smoke detection” was created, followed by a notification to the phone. The test was carried out with a fireplace match. The sensor passed the test successfully. The hub flashed an alarm, plus the sound alert worked. The sensor itself was also very disgusting and squeaked loudly, warning of a problem.

Smart home with Xiaomi on the example of a bath
Another sign of a fire is an increase in temperature. To control the temperature, two sensors were installed: one in the rest room, the other in the washroom. Further, the scenario “in case of a temperature above the set one” was configured in the application with a corresponding notification on the phone. At the moment, I set the threshold for the rest room to be 30 degrees (in the summer, it will probably need to be reconfigured).

Smart home with Xiaomi on the example of a bath
The scenario “in case of temperature below the set one” was also set up with a threshold of 18 degrees and alerts to the phone. If for some reason the heating stops working, I would like to know about it as soon as possible. Similarly, scenarios “in the event of an increase in humidity” were created for both sensors with a threshold of 70%, a notification on the phone and turning off the water supply pump.

Of the pleasant bonuses for temperature and humidity sensors, historical graphs are available in the application. You can, for example, determine at what moments the bath was used for its intended purpose (temperature peaks in the graph below) or compare whether the current temperature is abnormal.

Smart home with Xiaomi on the example of a bath

Ventilation control

In the steam room, a forced exhaust from the room is organized. After completion of the procedures, it is desirable to ventilate the room. The inclusion of ventilation is done by a key switch, and ventilation itself takes at least 30 minutes. However, often gatherings in the bathhouse end at the first or second hour of the night. It’s not always possible to do everything in advance, and sitting at the end of an additional 30 minutes and waiting for the steam room to air out is a pleasure below average due to the fact that you want to sleep already.

For this scenario, a key switch from Xiaomi with a zero line and wall mounting was required. The issue price is approximately 1900 rubles. The switches are available in the Aqara version for the local market.

In my case, it is impossible to simply replace an ordinary switch with a smart one - a power line is required. Accordingly, I had to stretch the zero line to the mounting hole for the switch, since there was such an opportunity. In the case of a circuit breaker without a neutral line, installation would be easier.

Smart home with Xiaomi on the example of a bath
After installation, the smart switch was added to the application as a device and its performance was tested. In the settings of the switch there is a timer, and you can set the time to turn off. That is, now before leaving the bath, a shutdown timer is set for an additional 30 minutes of ventilation, and you can safely go to sleep.

Smart home with Xiaomi on the example of a bath
There is another option for automating the process. After the end of the bath procedures, in addition to ventilation, the door to the steam room opens completely. This leads to an increase in the temperature in the washroom where the temperature sensor is installed. Based on the readings of this sensor, you can create scenarios for turning on / off ventilation. But I haven't tested this option yet. In addition, one could experiment with a sensor for opening the door to the steam room. But, I'm afraid, he will quickly die or fall off, since the door is made of glass, and in the steam room it can be 120 degrees.

street light control

Another task that I wanted to automate was the control of street light on the veranda. One of the typical scenarios: turn on the light on the veranda when you are close to the building and it is dark outside. The bath is locked with a key, the street light switch is located inside the room. I had to go for the key to open the door and turn on the light. Turning off the lights required a similar procedure. Another scenario that came up regularly was turning the veranda lights on or off when you were in the main house. Quite often, when leaving the bathhouse, I forgot to turn off the light on the veranda and discovered this when I was already in the house: either by looking out the window or by looking at the surveillance cameras. At this moment, it is usually reluctant to go anywhere, so the light continued to burn all night.

Smart home with Xiaomi on the example of a bath
To implement this idea, a two-channel relay was purchased. The issue price is approximately 2000 rubles. Relays in the Aqara version for the local market are not currently available. But it can be replaced with a key switch (it is clear that installing it in a switch box is a more troublesome process).

Initially, I planned to mount the relay behind the key switch, but it turned out to be very problematic to reach the right place for the power line (the relay needs power again). The ideal place is a junction box where the power line, the line from the switch, and the lines from the street lights converged. It was under a false ceiling, because of which several lining rails had to be dismantled. It would have been nice to have thought about this in advance. However, the installation was successful. The connection diagram is noticeably more complicated than for sockets and switches (in my case, four 3-wire wires and 8 terminals on the relay itself). In order not to keep in mind and not confuse anything, I painted the diagram on a piece of paper before mounting. Next, I did a test installation to check everything:

Smart home with Xiaomi on the example of a bath
The device has been connected in the application, and the testing phase has begun. The street light had to be switched on/off both with the pre-existing rocker switch and with the help of the application. There are two lanterns on the street - one on the left, the other on the right. The relay has two channels, but it did not make sense to turn them on separately. On the other hand, I also didn’t want to turn them on in turn with two clicks in the application. Therefore, the control was done on one relay channel. By a strange coincidence, this option did not work normally - sticking occurred in one or another position. There was not much time for experiments anymore, since the daylight hours were ending and I wanted to assemble the lining on the ceiling back. Therefore, I simply hooked the lights in parallel to both channels and everything worked as I wanted. In order for the physical and software switches to work as walk-through switches, the Interlock option was enabled in the relay settings.

It would also be possible to organize the on / off of the light on a timer. But this scenario has not yet interested.

Access control to the premises

Another curious moment was the control over the opening of the street door. First of all, to determine and notify that someone forgot to close this very door normally or left it completely open.

For this scenario, a window / door opening sensor was needed. The price of the issue is approximately 1000 rubles. There are sensors made by Aqara for the local market (they have less rounded edges).

Smart home with Xiaomi on the example of a bath
Installation is very simple - the sensors are attached with double-sided tape. Before mounting, it is better to connect the sensor in the application in order to see at what distance the operation occurs. The instructions write about a gap of up to 20 mm, but this, to put it mildly, is not true - the sensor and the reciprocal magnet have to be mounted almost closely. In the main house, a similar sensor is installed on the garage door. There is a sealing rubber 1 cm wide between the guide and the collar. At this distance, the sensor showed the “open” position and it was necessary to increase the response magnet.

After a new device has been added to the application, you can move on to automation. We set up the scenario “if the door is open for more than 1 minute” with a notification to the phone. In English localization, a part of the phrase about 1 minute is not visible, but the response threshold is exactly that. In the variant of the Aqara sensor and the Aqara Home application, other response intervals can be configured. As part of the Xiaomi Home application, this cannot be done yet, unfortunately. But practice has shown that an interval of 1 minute is more than sufficient - there are no false positives, all positives were on the case. You can also view logs by sensors. This sensor is no exception. It is possible, for example, to determine from the log when they came to the bathhouse (the first opening of the door on a given day) and when they left it (the last closing of the door), thereby estimating the total time spent in the room.

Smart home with Xiaomi on the example of a bath

Impressions from the operation

General impressions of operation are purely positive. Of course, there are some minor nuances, but the main goal of automation has been achieved. First of all, it is psychological calm, confirmed by test results. Comfort is also important - remote control of street lighting, an exhaust hood was received, an additional night lamp appeared. Having gone on vacation, you can remember and remotely turn off the water.

The costs for all the above devices in an approximate form (without reference to a specific store) are given below. When ordering on AliExpress, prices will differ downwards.

Smart home with Xiaomi on the example of a bath
When choosing a set of equipment, compatibility must be taken into account (for which region this equipment was produced and which family it belongs to). Within the application, it will not be possible to create a script that, for example, upon a smoke sensor event (for the “China Mainland” region), will control an outlet for the European region. If you don’t need exotics like a smoke detector, then it’s better to look at Aqara devices for the local market. In the end, the relay can be replaced, for example, with a two-gang switch. A number of stores selling Xiaomi devices seem to be importing them in gray (these devices are for the Chinese region). But, for example, Svyaznoy is carrying devices intended for our market. In addition to the compatibility of the same sockets, they will also have instructions in English and Russian. Below is a photo of two identical sensors, but for different regions (internal Chinese - on the left and external European - on the right):

Smart home with Xiaomi on the example of a bath
Responsiveness of control through the application is not always good. For example, sometimes you may encounter a situation that over and over again, instead of turning on the light, we get an error in the spirit of “request failed”. An experimentally identified cure - unloading the application from memory and restarting - solves this problem faster than waiting for a response on the next attempt. Also, sometimes there are noticeable delays (up to 20-30 seconds) with updating the status of a particular sensor. At these moments, it is better not to press the on / off buttons again, but simply wait for the status update. When you run the application, in some situations you may see an empty list instead of a list of devices. There is no need to panic here - it usually appears within the next few seconds. Notifications on the phone are not localized and the correct naming of the events themselves saves. In addition, the authors of the app periodically use the push notification channel for advertisements (again in Chinese). I don't like it, of course, but I don't have much of a choice.

I hope this article has helped to get a sufficient understanding of the capabilities of a number of Xiaomi devices for building a smart home and scenarios for their practical application. If you still have any questions, there are corrections and additions, I will be glad to discuss them in the comments.

Source: habr.com

Add a comment