biner88 / homebridge-mi-waterpuri

MiWaterPurifier for homebridge
GNU General Public License v3.0
5 stars 0 forks source link

Any plan to include Xiaomi Water Purifier 1A to the supported device list? #1

Closed Aekung closed 3 years ago

Aekung commented 3 years ago

Hi,

I'm currently using Xiaomi Water Purifier 1A. Not sure if you can also add support for this device?

The model is yunmi.waterpuri.lx5

Any information you need in order to make supporting this device work, please let me know.

Thank you very much.

biner88 commented 3 years ago

Hello

  1. Please find the MiWaterPurifier.js file in your homebridge/node_modules/homebridge-mi-waterpuri/Devices directory, and add the following code to line 118
    that.platform.log.info(result);
  2. Then restart Homebridge, the data printed by MiWaterPurifierPlatform looks like this
    [6/15/2021, 10:27:31 PM] [MiWaterPurifierPlatform] [
    207, 34, 870, 3453, 920,
    3586, 470, 3447, 480, 3471,
    3600, 4320, 3600, 8640, 7200,
    17280, 3600, 8640, 0, 1,
      0, 1, 0
    ]
  3. Provide the data of your Mijia water purifier
Aekung commented 3 years ago

that.platform.log.info(result);

Thanks for the reply.

I'm not sure if I have done it right but I added the line to line 118 so it's now look like this

that.platform.log.debug("[MiWaterPurifier][DEBUG]MiWaterPurifier - getWaterDensity: " + result); that.platform.log.info(result);

I still don't get the result as shown in your post. I only got

[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:16] [homebridge-mi-waterpuri] This plugin slows down Homebridge. The read handler for the characteristic 'Current Ambient Light Level' was slow to respond! See https://git.io/JtMGR for more info.
[16/06/2021, 00:00:17] [MiWaterPurifierPlatform] [MiWaterPurifier][ERROR]MiWaterPurifier - getWaterDensity Error: Error: user ack timeout
[16/06/2021, 00:00:17] [MiWaterPurifierPlatform] [MiWaterPurifier][ERROR]MiWaterPurifier - getWaterDensity Error: Error: user ack timeout
[16/06/2021, 00:00:17] [MiWaterPurifierPlatform] [MiWaterPurifier][ERROR]MiWaterPurifier - getWaterDensity Error: Error: user ack timeout
[16/06/2021, 00:00:17] [MiWaterPurifierPlatform] [MiWaterPurifier][ERROR]MiWaterPurifier - getWaterDensity Error: Error: user ack timeout

All the IP and Token in config file is correctly put. I'm not sure what have I done wrong so the result is not showing like in your instruction.

Any suggestion?

Aekung commented 3 years ago

Tried restarting in debug mode also gave me nothing close to your example.

Any way I could get that information for you, please kindly suggest and I will do so.

Thank you.

Aekung commented 3 years ago

Found this but not really sure if it helps

https://www.openhab.org/addons/bindings/miio/#yunmi-waterpuri-lx5

biner88 commented 3 years ago

Thanks, maybe this is possible. But it needs to be tried again. Please add code on line 118,and restart.

this.device.call("get_prop", ["run_status", "tds_in", "tds_out"]).then(result => {
       that.platform.log.info(result);
 }).catch(function (err) {
      that.platform.log.error(err);
 });
Aekung commented 3 years ago

this.device.call("get_prop", ["run_status", "tds_in", "tds_out"]).then(result => { that.platform.log.info(result); }).catch(function (err) { that.platform.log.error(err); });

I did add the code to line 118 and here is how the code looks like

MiWaterPurifierService
        .getCharacteristic(getChar)
        .on('get', function (callback) {
            this.device.call("get_prop").then(result => {
            this.device.call("get_prop", ["run_status", "tds_in", "tds_out"]).then(result => {
            that.platform.log.info(result);
            }).catch(function (err) {
            that.platform.log.error(err);
            });
                that.platform.log.debug("[MiWaterPurifier][DEBUG]MiWaterPurifier - getWaterDensity: " + result);
                var res
             ........;

Again, the information we are looking for is not yet shown.

I suspect that I might put the code in the wrong block somehow. What I did is adding those lines of code directly on line 118 so the rest of the previous code is still kept untouched but being pulled down to lower line instead.

Please let me know if I have done things correctly.

Thank you in advance.

Aekung commented 3 years ago

I changed the code to something like this.

MiWaterPurifierService
        .getCharacteristic(getChar)
        .on('get', function (callback) {
            this.device.call("get_prop", ["run_status", "tds_in", "tds_out"]).then(result => {
            that.platform.log.info(result);
            }).catch(function (err) {
            that.platform.log.error(err);
            });
                this.device.call("get_prop").then(result => {
                that.platform.log.debug("[MiWaterPurifier][DEBUG]MiWaterPurifier - getWaterDensity: " + result);
                var res;
........

And now I get a result, hopefully that it's what we are looking for

[16/06/2021, 16:10:51] [MiWaterPurifierPlatform] [ 0, 80, 39 ]

Is this really what we are looking for?

Aekung commented 3 years ago

I tried to add more variables in the "get_prop" and here is the result I have

[16/06/2021, 16:30:18] [MiWaterPurifierPlatform] [
  'error', 0,    29,
  0,       80,   39,
  7200,    8640, 1370,
  8148,    7200, 17280,
  1370,    8148
]

These values are in this respective order;

this.device.call("get_prop", ["power", "run_status", "temperature", "rinse", "tds_in", "tds_out", "f1_totalflow", "f1_totaltime", "f1_usedflow", "f1_usedtime", "f2_totalflow", "f2_totaltime", "f2_usedflow", "f2_usedtime"]).then(result => {

I stopped at f2 since my device only have 2 filters. Adding f3 shows no result of these values at all.

Based on this, I guess "power" value can't be feed for my model but the rest from "run_status" to "f2_usedtime" gives result as shown above.

Will it be possible to implement yunmi.waterpuri.lx5 in this plugin?

biner88 commented 3 years ago

Very good, it seems that more devices can be supported. Please wait 1-2 days, I will update this plugin.

Aekung commented 3 years ago

Very good, it seems that more devices can be supported. Please wait 1-2 days, I will update this plugin.

Thank you very much @biner88.

Looking forward to the updated plugin =)

biner88 commented 3 years ago

Plugin has been updated.

Aekung commented 3 years ago

Plugin has been updated.

Tested and Confirmed that it's working as it should be now. Thing is the TDS IN and TDS OUT seems to show correctly for my model but the PP Cotton and RO Remaining seems to be different as my device only have 2 filters. It seems to me the the PP Cotton Filter shows 19 lux, which represents the filter number 1 in my case (it has 5% remaining in Mi Home App) and the Front Active Carbon Filter Remaining shows 379 lux, which should represent my RO filter which is reporting 52% remaining in Mi Home App. Though I'm now sure how 52% remaining is converted to 379 lux and 5% remaining is converted to 19 lux.

PS. According to the values I got from debug, I don't see both 19 and 379 values. I am not really sure now what are these 2 values represent. Do you have any advice on this?

Thank you.

biner88 commented 3 years ago

The number of days the corresponding filter element can be used。

Aekung commented 3 years ago

The number of days the corresponding filter element can be used。

Ohhh, thank you very much @biner88

I got it now. Thanks for updating the plugin to include various Mi Water Purifier Models.

^^

biner88 commented 3 years ago

Thanks for your feedback.

Aekung commented 3 years ago

One more thing,

I enable only 2 values, which are TDS IN and TDS OUT and now the TDS IN tile reports the number correctly at 80 while TDS out is at 39, which is also correct according to Mi Home App. However, in Homekit Conclusion Tile (when you are not doing long press on the tile to show the lux sensor individually) the lux report at 60. I'm not sure where is this 60 from since the TDS In is 80 and TDS Out is 39.

There are no other light sensor in this room so the source of the number should come from the plugin directly.

biner88 commented 3 years ago

I don't know this either. However, Homekit does not have water purifier accessories and can only be replaced by lighting accessories. This may be calculated internally by Homekit. And I don’t have an IOS device, so I can’t test it. Really Sorry.

Is it an average?

Aekung commented 3 years ago

I don't know this either. However, Homekit does not have water purifier accessories and can only be replaced by lighting accessories. This may be calculated internally by Homekit. And I don’t have an IOS device, so I can’t test it. Really Sorry.

Nah, no need to say sorry. This is already more than what I can ask for. I'm so thankful of your help porting this plugin for my model and more.

I'm guessing that it could be an average value as well. Since when I enabled RO filter remaining days, the value raise up to 169 something, which seems to be the average of all numbers since the RO filter remaining days is 379.

Meanwhile, I'm only using TDS OUT to make sure that the number shown is really the quality of my drinking water since this matters the most. If and when the value gets high, I can set automation to alert me to check for the life of my filters in Mi App and this should already be great enough.

Again, thank you very much.

PS. Will post about your plugin on Reddit as I have seen someone asking about Homebridge Plugin for Xiaomi Water Purifier before.