Connecting Elehant water meters to the OpenHAB smart home

6 years of life in the house flew by unnoticed and now it’s time to trust or change the water meter. Let me explain that I have a city water supply and sewerage system in my house, so I am billed for water, and the volume of water disposal (sewerage) is considered equal to water consumption, and since the prices of the Izhevsk water utility have been growing very noticeably in recent years, I decided to use the option with the installation of an additional meter for water for irrigation, which is not taken into account when determining the payment for sewage. Some, for the sake of economy, make separate wells for irrigation, but I have applied advanced irrigation technologies to reduce water consumption for irrigation, and the watering itself is regulated by a smart home, so the consumed volumes are small (yes, I have a small area). But I have a humidifier and it sprays about a cubic meter of water around the house per day, and this water does not enter the sewer, but is removed by the exhaust ventilation to the street. In fact, for the sake of not paying for the sewage system for those volumes of water that go into the air, I decided to change the connection scheme and install an additional meter. Vodokanal explained to me on the phone what the scheme for installing meters should be. The plumbers soldered my pipes pretty well and installed new meters.

That was a saying, but now I will turn to the interesting. 6 years ago I studied counters and the price of counters with the issuance of specific numbers was sky-high. The alternative was in counters that gave out pulses. A controller was installed to them, which read them and transmitted them further to the smart home for display. I have implemented such a system, but it had drawbacks in the face of volatility and the need to make corrections if water was used in the absence of electricity. But the years have passed and budget meters have appeared that have a BLE wireless interface, which is widespread among smart home gadgets. It differs from Zigbee in its simplicity of implementation and is becoming more and more popular. In particular, Xiaomi, which previously used Zigbee, is now releasing new device models with BLE. Well, in search of smart meters this year, I came across counters Elehant, which stand as pulse counters, but at the same time, the data is issued precisely through BLE. So I ordered them in Ozon and took them for 4 days in the nearest “Perkrestok-type grocery store” (there we have Ozon issuance and Halva checkpoint where DPD brings parcels from Aliexpress). Counters cost 1,320 rubles each, while the price of the simplest meter is ~ 600 rubles, and the price of impulse meters is much more expensive than Elehantna.

The meters look cool, since instead of numbers they have a QR code for downloading the application and the number of the meter itself, but you cannot see the readings on it! At the same time, it is stated that the battery lasts for 6 years and during the calibration, it is necessary to change the battery every 6 years. Data in BLE. They give data in BLE in the field “manufacturer”, that is, the manufacturer’s data without decoding and breaking into fields. I wrote to the manufacturer’s technical support asking if there was any documentation about what they were broadcasting. To which they answered me – “this is a commercial secret”, which was expected and extremely stupid, of course, since the search gave, even before I asked the question, several implementations of extracting this very data. The most interesting and understandable options for me turned out to be here This article… From there I took the test script and the layout of the fields, and then rewrote the transformations in a convenient form right in OpenHAB.

In order to receive data from BLE and send it to MQTT and through it to OpenHAB, I use a gateway LUMI European version from Xiaomi with OpenWrt firmware where BLE is enabled (by default it is not used and the interface is inactive). I must say right away that Xiaomi does not use this interface and offers to buy new models of gateways for new sensors !!! Such is the marketing !!! So, if someone there tells tales about slowing down the iPhone, you better feel how the Chinese simply stupidly offer to change the piece of hardware due to the fact that the software does not want to fix their own. Korome of OpenWrt itself, the EspruinoHub package and Zigbee2MQTT are installed on the gateway, of course. The first sends everything received from BLE to the MQTT broker and back, and the second also connects Zigbee in both directions.

Having received such information, I enter the counter in OpenHAB as a thing and prescribe channels that, except for the signal level, process the ble / advertise / b0: 01: 02: 00: bc: f6 / manufacturer / ffff topic, but different scripts are used for processing. receiving different information or information in different formats.

To get the value of water consumption in tenths of a liter, I use the Incoming Volume Transformation JS: elehant_vol_cl.js right in the advanced channel settings. The script itself lies in the transform directory and is a simple JavaScript procedure:

(function (i) {var str = i.replace (/ “/ g, ”);
return parseInt ((str.substr (24,2) + str.substr (22,2) + str.substr (20,2) + str.substr (18,2)), 16)}) (input)

for the script to work, it needs a local variable and when it is defined, spaces are truncated if they suddenly appear in the output. The string is formed in the correct sequence and it is converted from hexadecimal to decimal. Since readings in cubic meters are submitted to the sales company, there is a script next to it where the result of dividing by 10,000 of this whole is returned.

For unambiguous identification of meters, it is useful to get their numbers directly from them, and this is done with the following script:

(function (i) {var str = i.replace (/ “/ g, ”);
return parseInt ((str.substr (16,2) + str.substr (14,2) + str.substr (12,2)), 16);
}) (input)

everything is the same as in the first, but other characters from the string are used.

PS: since I have not mastered this WP clone, the original is here https://ae11.me/archives/8332

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *