syssi / xiaomi_airpurifier

Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier integration for Home Assistant
Apache License 2.0
446 stars 109 forks source link

Add shuii.humidifier.jsq002 support #50

Open iceveil opened 4 years ago

iceveil commented 4 years ago

shuii.humidifier.jsq002 is not support

iromeo commented 4 years ago

A related issue for shuii.humidifier.jsq001 support, see #52.

@iceveil Could you check communication protocol and supported features like I've did in https://github.com/rytilahti/python-miio/issues/642, should be helpful for 002 version.

iromeo commented 4 years ago

@iceveil Hi, I've added support for shuii.humidifier.jsq001, I could help you with shuii.humidifier.jsq002 support or you could help me. So get in touch with me if you are still interested.

syssi commented 3 years ago
# Methods
get_props []
on_off 0 # off
on_off 1 # on 
set_gear [0]
set_gear [1]
set_gear [2]
set_gear [3]
warm_on 0 # off
warm_on 1 # on
buzzer_on 0 # off
buzzer_on 1 # on
set_lock 0 # off
set_lock 1 # on
set_temp [int]
set_humidity [int]
set_led [1]
set_led [2]
set_led [3]
corrected_water []
rst_clean []

# bea: buzzer_on
# lock: set_lock
# temperature: set_temp
# humidity: set_humidity
# led: set_led
fast_set [bea, lock, temperature, humidity, led]
          0/1,  0/1,          25,       50, 0/1]

# Properties

power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false,
gear: res[1],
humidity: res[2],
ledLevel: res[3],
temperature: res[4],
waterLevel: res[5],
heat: res[6] == 1 ? true : false,
beaPower: res[7] == 1 ? true : false,
childPower: res[8] == 1 ? true : false,
targetTemp: res[9],
targetHumidity: res[10],
errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : ''

[power, gear, humidity, ledLevel, temperature, waterLevel, heat, beaPower, childPower, targetTemp, targetHumidity]
[true,     1,       50,        1,          25,    [0...6], false,   false,      false,          0,              0]

@iromeo Do you like to support here?

syssi commented 3 years ago

@iceveil Could you provide some testing?

vhardono commented 3 years ago

any chance to have shuii.humidifier.jsq001 added in Homebridge environment?

Glebon80 commented 3 years ago

@iceveil Could you provide some testing?

I can test shuii.humidifier.jsq002

AleksandrBoyarshinov commented 2 years ago

Hello! Can't add shuii.humidifier.jsq002? How can I help?

AleksandrBoyarshinov commented 2 years ago
# Methods
get_props []
on_off 0 # off
on_off 1 # on 
set_gear [0]
set_gear [1]
set_gear [2]
set_gear [3]
warm_on 0 # off
warm_on 1 # on
buzzer_on 0 # off
buzzer_on 1 # on
set_lock 0 # off
set_lock 1 # on
set_temp [int]
set_humidity [int]
set_led [1]
set_led [2]
set_led [3]
corrected_water []
rst_clean []

# bea: buzzer_on
# lock: set_lock
# temperature: set_temp
# humidity: set_humidity
# led: set_led
fast_set [bea, lock, temperature, humidity, led]
          0/1,  0/1,          25,       50, 0/1]

# Properties

power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false,
gear: res[1],
humidity: res[2],
ledLevel: res[3],
temperature: res[4],
waterLevel: res[5],
heat: res[6] == 1 ? true : false,
beaPower: res[7] == 1 ? true : false,
childPower: res[8] == 1 ? true : false,
targetTemp: res[9],
targetHumidity: res[10],
errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : ''

[power, gear, humidity, ledLevel, temperature, waterLevel, heat, beaPower, childPower, targetTemp, targetHumidity]
[true,     1,       50,        1,          25,    [0...6], false,   false,      false,          0,              0]

Methods checked everything works. I don't know how to check Properties.

iromeo commented 2 years ago

Methods checked everything works

@AleksandrBoyarshinov Hi, as far as I understand, you able to send commands to device via python-miio library. So in order to check properties you could do following steps:

1) get current state of you device: (like in https://github.com/rytilahti/python-miio/issues/642) dev.send("get_props","") you will get smth like: [24, 37, 3, 1, 0, 2, 1, 0, 0] 2) now try some feature, e.g. enable child mode on the device, get current state again and check which number changed, 3) repeat step 2 for all properties, ensure the numbers in list matches the above definition:

[power, gear, humidity, ledLevel, temperature, waterLevel, heat, beaPower, childPower, targetTemp, targetHumidity]
[true,     1,       50,        1,          25,    [0...6], false,   false,      false,          0,              0]

and

power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false,
gear: res[1],
humidity: res[2],
ledLevel: res[3],
temperature: res[4],
waterLevel: res[5],
heat: res[6] == 1 ? true : false,
beaPower: res[7] == 1 ? true : false,
childPower: res[8] == 1 ? true : false,
targetTemp: res[9],
targetHumidity: res[10],
errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : ''
iromeo commented 2 years ago

@iromeo Do you like to support here?

Hi, sorry I missed your question. If @AleksandrBoyarshinov isn't going to implement it by himeself, I could try to support this.

AleksandrBoyarshinov commented 2 years ago

All values match and change if you change them in the application, except for the last 0 you don't have it. I can also send commands from the computer and the humidifier responds to them.

dev.send("get_props","") [0, 2, 37, 2, 46, 4, 1, 1, 0, 50, 50, 0]

dev.send("get_props","") [0, 2, 37, 2, 46, 4, 1, 1, 0, 50, 50, 0] dev.send("get_props","") [0, 2, 37, 2, 46, 4, 1, 1, 0, 50, 50, 0] dev.send("get_props","") [1, 2, 37, 2, 46, 4, 1, 1, 0, 50, 50, 0] dev.send("get_props","") [1, 2, 36, 2, 46, 4, 1, 1, 1, 50, 50, 0]

On these commands

power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false,
gear: res[1],
humidity: res[2],
ledLevel: res[3],
temperature: res[4],
waterLevel: res[5],
heat: res[6] == 1 ? true : false,
beaPower: res[7] == 1 ? true : false,
childPower: res[8] == 1 ? true : false,
targetTemp: res[9],
targetHumidity: res[10],
errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : ''

gives errors or I'm doing it wrong

power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false, File "", line 1 power: res[0] == 1 ? res[5] == 0 || res[5] == 6 ? false : true : false, ^ SyntaxError: invalid syntax gear: res[1], File "", line 1 gear: res[1], ^ SyntaxError: invalid syntax gear: res[1] Traceback (most recent call last): File "", line 1, in NameError: name 'res' is not defined

iromeo commented 2 years ago

gives errors or I'm doing it wrong

Yes, this part isn't a working python code, it is some kind of documentation with suggested meaning of values in [1, 2, 36, 2, 46, 4, 1, 1, 1, 50, 50, 0] written in some python-like style, but not correct python code.

repeat step 2 for all properties, ensure the numbers in list matches the above definition:

My suggestion was to test, that above description is correct, e.g. that we correctly undestand what number in each position means and there is no mistakes there, i.e in your case

[1, 2, 36, 2, 46, 4, 1, 1, 1, 50, 50, 0] means:

AleksandrBoyarshinov commented 2 years ago

I have corrected the Values

1: is power, values: 1 for ON and 0 for OFF / sleep mode 2: gear: fan speed mode have values: 1,2,3. 36: humidity level 2: led brightness mode with values: 1,2,3 46: Temperature (For some reason it shows 20 more than the correct value of 26) 4: water level with values: 0,1,2,3,4,5 1: heat mode with values 1 is ON, 0 is OFF 1: beaPower with values 1 is ON, 0 is OFF 1: child mode with values 1 is ON, 0 is OFF 50: target temperature 50: target humidity 0: I don't know what it is either. There is still a timer in the application, but it does not react to it in any way.

I checked all this

iromeo commented 2 years ago

@AleksandrBoyarshinov thx! By the way, what does beaPower means? Also, do you want to implement this feature by yourself or do you prefer to delegate it to somebody here (e.g. I could fix it using the above information checked by you) ?

iromeo commented 2 years ago

46: Temperature (For some reason it shows 20 more than the correct value of 26)

Is the same is with 50: target temperature ? E.g. you current target temp is 30, not 50?

AleksandrBoyarshinov commented 2 years ago

@AleksandrBoyarshinov thx! By the way, what does beaPower means? Also, do you want to implement this feature by yourself or do you prefer to delegate it to somebody here (e.g. I could fix it using the above information checked by you) ?

beaPower - bizzer (sound signal) I prefer to delegate. I can't do it on my own, I don't have enough knowledge.

AleksandrBoyarshinov commented 2 years ago

46: Temperature (For some reason it shows 20 more than the correct value of 26)

Is the same is with 50: target temperature ? E.g. you current target temp is 30, not 50?

No, it's all right here. This humidifier has a heater (for rapid evaporation). This value sets the water heating temperature. In the application, it can take values from 30 to 60 °. Any value can be sent from the computer.

iromeo commented 2 years ago

I prefer to delegate.

Ok, I'll try to do it next weekend. First, we need to send a fix into python-miio driver library (https://github.com/rytilahti/python-miio), and after they accept it we could attach a fix for HomeAssistant integration here.

AleksandrBoyarshinov commented 2 years ago

Thank you.

iromeo commented 2 years ago

@AleksandrBoyarshinov Hi, I'vw started working on fix into python-miio library. I have more questions on the information above:

1) Could be temperature is not room temperature, but water / heater temp in tank? You said

46: Temperature (For some reason it shows 20 more than the correct value of 26) and then

This humidifier has a heater (for rapid evaporation). This value sets the water heating temperature. In the application, it can take values from 30 to 60 °. Any value can be sent from the computer.

it is reasonable to assume, that temperature and target_temperature should match

2)

0: I don't know what it is either. There is still a timer in the application, but it does not react to it in any way.

model jsq001 have lid opened property. Could you check , maybe last one is lid open state, e.g. 0 - closed, 1 - opened. Or maybe some cleaning mode.

3)

2: led brightness mode with values: 1,2,3

Normally they also support 0 value, when led if off. Is it true here? Seems you missed 0 value. How are these modes named in MiHome app. E.g. for jsq001 they are: Off, Low, High

4)

2: gear: fan speed mode have values: 1,2,3.

Similar question. Does it provide 0 for silent / intellijent / etc mode? E.g. in jsq001 0 corresponds to Intelligent. How are these modes named in MiHome app. E.g. for jsq001 they are: Intellijent, Level1, ... Level4

5) What is the English name of the device? e.g. shuii.humidifier.jsq001 is Xiaomi Zero Fog Humidifier

6) To submit a request into python-miio, they as provide information:

Use `miiocli device --ip <ip address> --token <token>`.

  - Model: [e.g., lumi.gateway.v3]
  - Hardware version:
  - Firmware version:

So model should be shuii.humidifier.jsq002.

AleksandrBoyarshinov commented 2 years ago

Hi

  1. Could be temperature is not room temperature, but water / heater temp in tank? You said

No, it's the ambient temperature. It does not show the water temperature. At the same time, the application displays correctly in one place, and in another place by 20 degrees more. (screenshots below) Screenshot_20211101-110224_Mi Home Screenshot_20211101-110231_Mi Home

2. I tried to open the lid, but it turns off completely. I tried all the modes in mihome, this 0 does not change.

3. Everything is correct here. 0 is not used. 1- off light 2- low light 3- hight light

4. Everything is correct here too. 0 is not used. 1- level 1 2- level 2 3- level 3

5. Zero Fog DWZF(G)-4500Z

6. Model: shuii.humidifier.jsq002 I don't know how to view hardware and firmware version

iromeo commented 2 years ago

I don't know how to view hardware and firmware version

How do you get status from the device? Am I right, that you have python-miio tool installed on your computer (https://python-miio.readthedocs.io/en/latest/)? If yes, then running command like

miiocli device --ip <ip> --token <token> info

(where <ip> and <token> should be substituted with your device IP and access token) Is suppsed to print smth like:

Model: some.device.model1
Hardware version: esp8285
Firmware version: 1.0.1_0012
Network: {'localIp': '<ip>', 'mask': '255.255.255.0', 'gw': '<ip>'}
AP: {'rssi': -73, 'ssid': '<nnetwork>', 'primary': 11, 'bssid': '<bssid>'}
AleksandrBoyarshinov commented 2 years ago

Model: shuii.humidifier.jsq002 Hardware version: ESP8266 Firmware version: 1.4.0

wxy8866 commented 2 years ago

Hi I have the device and am able to test. shuii.humidifier.jsq002 Please let me know how to do it.

iromeo commented 2 years ago

@AleksandrBoyarshinov Hi, sorry for long delay. I have some time, so returned to the issue and implemented one more chunk of the feature. Also I have several new questions:

corrected_water [] rst_clean []

Somewhere above it was mentioned that the device supports corrected_water and rst_clean commands.

errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : ''

You already mentioned that the water level could be 0,1,2,3,4,5. The above message tells that there is some warning about water overflow and value will be 6. Is it true?

set_humidity [int]

What values does set_humidity allows to set? E.g. could I set any number from 0..99 range? Or only some nice looking values like 30, 40, 50 ? Does it allow to set 100 or smth above (e.g. 144) ? What values will be then returned by get_props ?

iromeo commented 2 years ago

@AleksandrBoyarshinov I implemented the suggested fix into python-miio library. The library is used by Home-Assistant and some other home automation solutions. So integration with Home-Assistant requires first fix into python-miio library and then fix into integration component. So I need some help with testing my fix + I'd like to know answers to the above questions (as for rst_clean - not critical). My instructions for the fix testing see in https://github.com/rytilahti/python-miio/issues/1171#issuecomment-1030844919.

AleksandrBoyarshinov commented 2 years ago

@iromeo Hi, thank you for your work.

corrected_water [] - an incomprehensible command. I do not know what it corrects, but after its input, the water level became 0, while there was water in the tank. I had to pour and pour water several times so that the humidifier could see the level.

rst_clean [] - after entering this command, the humidifier emits a squeak, but nothing changes in the application or on the humidifier itself. There is no cleaning function or anything like that in the application.

dev.send("rst_clean", [0]); ['ok'] dev.send("rst_clean", [1]); ['ok']

errTips: res[5] == 0 ? "Water shortage" : res[5] == 6 ? "Overflow: warning" : '' - If you pour water into the humidifier after level 5, it emits a warning about overflow or fullness - a sound (squeak).

set_humidity [int] - Here you can set any value from 0 to 99. If you set 100, it gives an error. If you set more than 100, then there will be numbers after 1 (for example: set the value to 135, it will be 35). In the application, you can set from 30 to 90.

iromeo commented 2 years ago

@AleksandrBoyarshinov

I had to pour and pour water several times

Sorry for that. Seems it is Zero water level calibration. Maybe instead of pouring several times, it was ok to run it again, when the tank is empty.

it emits a warning about overflow or fullness -

And the level is still reported as 5 after warning, correct? Is it true to consider that level 5 means overflow? I.e. 4-5 is max valid level, and starting from 5 is possible overflow?

AleksandrBoyarshinov commented 2 years ago

@iromeo

And the level is still reported as 5 after warning, correct?

Yes, that's right. I pour water, the fifth division lights up and if I continue to pour, then a signal will sound in a few seconds

Is it true to consider that level 5 means overflow? I think 5 is full

AleksandrBoyarshinov commented 1 year ago

Can't connect this humidifier?