Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status not worked for AirHumidifier CA1 #383

Closed
charger opened this issue Oct 1, 2018 · 20 comments
Closed

Status not worked for AirHumidifier CA1 #383

charger opened this issue Oct 1, 2018 · 20 comments

Comments

@charger
Copy link

charger commented Oct 1, 2018

Hi,
I have a problem with controlling Xiaomi (SmartMi) Humidifier 2:
firmware version: 1.5.6.1024
python-miio version: 4.0.1

Here is my code:

from miio import AirHumidifier
h = AirHumidifier("192.168.1.60", "token")
h.status()

and what I got:

Traceback (most recent call last):                                                                                                                    
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 257, in send                                                                     
    data, addr = s.recvfrom(1024)                                                                                                                     
socket.timeout: timed out                                                                                                                             
                                                                                                                                                      
During handling of the above exception, another exception occurred:                                                                                   
                                                                                                                                                      
Traceback (most recent call last):                                                                                                                    
  File "<stdin>", line 1, in <module>                                                                                                                 
  File "/usr/local/lib/python3.7/site-packages/miio/airhumidifier.py", line 254, in status                                                            
    properties                                                                                                                                        
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 286, in send                                                                     
    return self.send(command, parameters, retry_count - 1)                                                                                            
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 270, in send                                                                     
    raise DeviceError(m.data.value["error"])                                                                                                          
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}

By the way h.on(), h.off(), and h.set_mode() works.

Do you have any clue what is wrong?

@syssi
Copy link
Collaborator

syssi commented Oct 2, 2018

Did you block the internet access of the device?

@charger
Copy link
Author

charger commented Oct 2, 2018

I didn't block the internet for the device.

@syssi
Copy link
Collaborator

syssi commented Oct 2, 2018

Alright! Could you provide the output of:

from miio import AirHumidifier
h = AirHumidifier("192.168.1.60", "token")
h.info()

@charger
Copy link
Author

charger commented Oct 2, 2018

Here it is:

zhimi.humidifier.ca1 v1.5.6 (34:CE:00:87:3F:58) @ 192.168.1.60 - token: 420f3458a065ca04eaf5f9baxxxxxxxx

@syssi
Copy link
Collaborator

syssi commented Oct 2, 2018

Perfect. Now we try to request some properties:

from miio import AirHumidifier
h = AirHumidifier("192.168.1.60", "token")
properties = ['power', 'mode', 'temp_dec', 'humidity', 'buzzer', 'led_b', 'child_lock', 'limit_hum', 'trans_level', 'speed', 'depth', 'dry', 'use_time', 'button_pressed', 'hw_version', ]
h.send("get_prop", properties)

Please reduce the property list step by step. There must be a property which isn't supported and must not be requested.

@charger
Copy link
Author

charger commented Oct 2, 2018

I'll tried this. Error the same:

>>> h.send("get_prop", properties)                                                                                                                    
Traceback (most recent call last):                                                                                                                    
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 257, in send                                                                     
    data, addr = s.recvfrom(1024)                                                                                                                     
socket.timeout: timed out                                                                                                                             
                                                                                                                                                      
During handling of the above exception, another exception occurred:                                                                                   
                                                                                                                                                      
Traceback (most recent call last):                                                                                                                    
  File "<stdin>", line 1, in <module>                                                                                                                 
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 286, in send                                                                     
    return self.send(command, parameters, retry_count - 1)                                                                                            
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 270, in send                                                                     
    raise DeviceError(m.data.value["error"])                                                                                                          
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}  

I found, that using one parameter works fine and returns answer but using two or more parameters gets Timeout error and turn off the device

>>> h.send("get_prop", ['power'])
['on']
>>> h.send("get_prop", ['mode']) 
['silent']

>>> h.send("get_prop", ['power', 'mode'])                                                                                                        
Traceback (most recent call last):
  File "<stdin>", line 1, in <module> 
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 270, in send                                                                     
    raise DeviceError(m.data.value["error"])                                                                                                          
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}                                                                               

>>> h.send("get_prop", ['power'])                                                                                                                     
['off']                    

@syssi
Copy link
Collaborator

syssi commented Oct 2, 2018

Could you request all properties one by one (f.e. by a foreach loop)? I want to make sure all properties are supported.

@syssi
Copy link
Collaborator

syssi commented Oct 2, 2018

There is a fan device (hardware) which has the same behavior: https://github.com/rytilahti/python-miio/blob/master/miio/fan.py#L287-L295

@charger
Copy link
Author

charger commented Oct 2, 2018

I checked all properties one by one and all works except:

  • "button_pressed" throw exception "timeout"
  • "trans_level" - returns "null" (and "abrakadabra" also returns "null)

@charger
Copy link
Author

charger commented Oct 2, 2018

Just in case: method "depth" returns water level. The maximum water level is 120.

@syssi syssi changed the title Status not worked for AirHumidifier Status not worked for AirHumidifier CA1 Oct 7, 2018
syssi added a commit to syssi/python-miio that referenced this issue Oct 7, 2018
@syssi
Copy link
Collaborator

syssi commented Oct 7, 2018

Could you install the fixed version just for testing:

$ pip3 install https://github.com/syssi/python-miio/archive/feature/fix-air-humidifier-ca1.zip -U
$ python3
from miio import AirHumidifier
h = AirHumidifier("192.168.1.60", "token", model="zhimi.humidifier.ca1")
h.status()

Thanks in advance!

@syssi syssi closed this as completed in 8569e75 Oct 8, 2018
@charger
Copy link
Author

charger commented Oct 8, 2018

I'm afraid there is the same error.
I updated library. pip list:

python-miio    0.4.2

And see slightly different stack trace:

>>> h.status()      
                                                                                                                                 
Traceback (most recent call last):                                                                                                                   
  File "<stdin>", line 1, in <module>                                                                                                                
  File "/usr/local/lib/python3.7/site-packages/miio/airhumidifier.py", line 295, in status                                                           
    values.extend(self.send("get_prop", _props[:_props_per_request]))                                                                                
  File "/usr/local/lib/python3.7/site-packages/miio/device.py", line 270, in send                                                                    
    raise DeviceError(m.data.value["error"])                                                                                                         
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}              

Asking one by one still works, but sometimes takes 15+ seconds:

>>> words=["power", "mode", "temp_dec", "humidity", "buzzer", "led_b", "child_lock", "limit_hum", "use_time", "hw_version", "speed", "depth", "dry"] 
>>> list(map(lambda w: h.send("get_prop", [w]), words))                                                                                              
[['off'], ['medium'], [222], [65], ['off'], [1], ['off'], [70], [2126993449], ['0001'], [0], [66], ['off']]

@zoral566
Copy link

sudo pip3 install https://github.com/syssi/python-miio/archive/feature/fix-air-humidifier-ca1.zip -U
miio discover
Device ID: 61993415
Model info: zhimi.humidifier.ca1
Address: 192.168.1.204
Token: 581386dbf6457cdf84aef497e6a167fa via stored token
Support: At least generic
pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

from miio import AirHumidifier
h = AirHumidifier("192.168.1.204", "581386dbf6457cdf84aef497e6a167fa", model="zhimi.humidifier.ca1")
h.status()
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python3.5/site-packages/miio/airhumidifier.py", line 232, in repr
self.strong_mode_enabled,
File "/home/pi/.local/lib/python3.5/site-packages/miio/airhumidifier.py", line 132, in strong_mode_enabled
if self.firmware_version_minor == 25:
File "/home/pi/.local/lib/python3.5/site-packages/miio/airhumidifier.py", line 153, in firmware_version_minor
, minor = self.firmware_version.rsplit('', 1)
ValueError: not enough values to unpack (expected 2, got 1)

@syssi
Copy link
Collaborator

syssi commented Nov 20, 2018

@zoral566 Could you provide the output of

# install master first
pip3 install -U https://github.com/rytilahti/python-miio/archive/master.zip
miiocli airhumidifierca1 --ip IP --token info
miiocli airhumidifierca1 --ip IP --token status

Thanks in advance!

@zoral566
Copy link

pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ sudo pip3 install -U https://github.com/rytilahti/python-miio/archive/master.zip
Collecting https://github.com/rytilahti/python-miio/archive/master.zip
Downloading https://github.com/rytilahti/python-miio/archive/master.zip
| 972kB 2.2MB/s
Requirement already up-to-date: construct in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: click in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: cryptography in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: pretty_cron in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: zeroconf in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: attrs in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: android_backup in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: pytz in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: appdirs in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: tqdm in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: netifaces in /usr/local/lib/python3.5/dist-packages (from python-miio==0.4.3)
Requirement already up-to-date: cffi!=1.11.3,>=1.7 in /usr/local/lib/python3.5/dist-packages (from cryptography->python-miio==0.4.3)
Requirement already up-to-date: idna>=2.1 in /usr/local/lib/python3.5/dist-packages (from cryptography->python-miio==0.4.3)
Requirement already up-to-date: six>=1.4.1 in /usr/local/lib/python3.5/dist-packages (from cryptography->python-miio==0.4.3)
Requirement already up-to-date: asn1crypto>=0.21.0 in /usr/local/lib/python3.5/dist-packages (from cryptography->python-miio==0.4.3)
Requirement already up-to-date: ifaddr in /usr/local/lib/python3.5/dist-packages (from zeroconf->python-miio==0.4.3)
Requirement already up-to-date: pycparser in /usr/local/lib/python3.5/dist-packages (from cffi!=1.11.3,>=1.7->cryptography->python-miio==0.4.3)
Requirement already up-to-date: ipaddress in /usr/local/lib/python3.5/dist-packages (from ifaddr->zeroconf->python-miio==0.4.3)
Installing collected packages: python-miio
Found existing installation: python-miio 0.4.2
Uninstalling python-miio-0.4.2:
Successfully uninstalled python-miio-0.4.2
Running setup.py install for python-miio ... done
Successfully installed python-miio-0.4.3

pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ miiocli airhumidifierca1 --ip 192.168.1.204 --token 581386dbf6457cdf84aef497e6a167fd info
Usage: miiocli [OPTIONS] COMMAND [ARGS]...
Try "miiocli --help" for help.

Error: No such command "airhumidifierca1".

pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ miiocli airhumidifierca1 --ip 192.168.1.204 --token 581386dbf6457cdf84aef497e6a167fd status
Usage: miiocli [OPTIONS] COMMAND [ARGS]...
Try "miiocli --help" for help.

Error: No such command "airhumidifierca1".

Thank you for dealing with the problem

@syssi
Copy link
Collaborator

syssi commented Nov 20, 2018

It looks like you've installed the package multiple times to different locations. The version you are calling (which miiocli) isn't python-miio 0.4.3.

pip3 install https://github.com/rytilahti/python-miio/archive/master.zip -U                                                                                                                                                                    
Collecting https://github.com/rytilahti/python-miio/archive/master.zip                                                                                                                                                                                                         
  Downloading https://github.com/rytilahti/python-miio/archive/master.zip                                                                                                                                                                                                      
     \ 1.0MB 73.1MB/s
Collecting android_backup (from python-miio==0.4.3)                                                                                                                                                                                                                            
Collecting appdirs (from python-miio==0.4.3)                                                                                                                                                                                                                                   
  Using cached https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl                                                                                                                   
Collecting attrs (from python-miio==0.4.3)                                                                                                                                                                                                                                     
  Using cached https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl                                                                                                                    
Collecting click (from python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
Collecting construct (from python-miio==0.4.3)
Collecting cryptography (from python-miio==0.4.3)
  Downloading https://files.pythonhosted.org/packages/ec/18/1583e40c38ff8572c42e56ce17b95357a9ebb91375cfbd7aad63cac9a32e/cryptography-2.4.1-cp34-abi3-manylinux1_x86_64.whl (2.1MB)
    100% |████████████████████████████████| 2.1MB 577kB/s 
Collecting netifaces (from python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/e9/25/6df71623bc2867ead3323265d548aa9bd27bfa5fd22b2486185d68b81c2b/netifaces-0.10.7-cp35-cp35m-manylinux1_x86_64.whl
Collecting pretty_cron (from python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/18/52/d981fdd2ff0dbe660cfad6a571c596adf65eb7b25d789bd5547ce5dfdf44/pretty_cron-1.2.0-py2.py3-none-any.whl
Collecting pytz (from python-miio==0.4.3)
  Downloading https://files.pythonhosted.org/packages/f8/0e/2365ddc010afb3d79147f1dd544e5ee24bf4ece58ab99b16fbb465ce6dc0/pytz-2018.7-py2.py3-none-any.whl (506kB)
    100% |████████████████████████████████| 512kB 1.2MB/s 
Collecting tqdm (from python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/91/55/8cb23a97301b177e9c8e3226dba45bb454411de2cbd25746763267f226c2/tqdm-4.28.1-py2.py3-none-any.whl
Collecting zeroconf (from python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/d2/4e/3e751bc1f33d0368bdba509a140cb9f2e54cd1cfb8ebcf4ebd8a5eef794b/zeroconf-0.21.3-py2.py3-none-any.whl
Collecting cffi!=1.11.3,>=1.7 (from cryptography->python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/59/cc/0e1635b4951021ef35f5c92b32c865ae605fac2a19d724fb6ff99d745c81/cffi-1.11.5-cp35-cp35m-manylinux1_x86_64.whl
Collecting six>=1.4.1 (from cryptography->python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting idna>=2.1 (from cryptography->python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography->python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting ifaddr (from zeroconf->python-miio==0.4.3)
Collecting pycparser (from cffi!=1.11.3,>=1.7->cryptography->python-miio==0.4.3)
Collecting ipaddress (from ifaddr->zeroconf->python-miio==0.4.3)
  Using cached https://files.pythonhosted.org/packages/fc/d0/7fc3a811e011d4b388be48a0e381db8d990042df54aa4ef4599a31d39853/ipaddress-1.0.22-py2.py3-none-any.whl
Installing collected packages: android-backup, appdirs, attrs, click, construct, pycparser, cffi, six, idna, asn1crypto, cryptography, netifaces, pretty-cron, pytz, tqdm, ipaddress, ifaddr, zeroconf, python-miio
  Running setup.py install for python-miio ... done
Successfully installed android-backup-0.2.0 appdirs-1.4.3 asn1crypto-0.24.0 attrs-18.2.0 cffi-1.11.5 click-7.0 construct-2.9.45 cryptography-2.4.1 idna-2.7 ifaddr-0.1.4 ipaddress-1.0.22 netifaces-0.10.7 pretty-cron-1.2.0 pycparser-2.19 python-miio-0.4.3 pytz-2018.7 six-1.11.0 tqdm-4.28.1 zeroconf-0.21.3

$ .local/bin/miiocli airhumidifierca1
Usage: miiocli airhumidifierca1 [OPTIONS] COMMAND [ARGS]...

Options:
  --ip TEXT     [required]
  --token TEXT  [required]
  --help        Show this message and exit.

Commands:
  info                 Get miIO protocol information from the device.
  off                  Power off.
  on                   Power on.
  raw_command          Send a raw command to the device.
  set_buzzer           Set buzzer on/off.
  set_child_lock       Set child lock on/off.
  set_dry              Set dry mode on/off.
  set_led_brightness   Set led brightness.
  set_mode             Set mode.
  set_target_humidity  Set the target humidity.
  status               Retrieve properties.

@zoral566
Copy link

zoral566 commented Nov 20, 2018

really was in two places. Under / home /pi/.local and / usr / local / bin /. i run run from (without sudo ) pip3 install https://github.com/rytilahti/python-miio/archive/master.zip -U
It works, thank you very much.

@lukaszantkowiak
Copy link

I have the same issue. status() not working and properties can be retrieved one by one, not all in one request.

'pip3 install https://github.com/rytilahti/python-miio/archive/master.zip -U' didn't solve my problem.

Commands for info and status work well.

pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ miiocli airhumidifierca1 --ip 192.168.1.20 --token b3026a0a55390cc375de32xxxxxxxxxx info
Model: zhimi.humidifier.ca1
Hardware version: MTK7697
Firmware version: 1.6.7
Network: {'localIp': '192.168.1.20', 'mask': '255.255.255.0', 'gw': '192.168.1.1', 'gw_mac': '78:44:76:DE:00:00'}
AP: {'rssi': -44, 'ssid': 'My WiFi SSID', 'bssid': '78:44:76:DE:00:00'}
pi@raspberrypi:~/domoticz/plugins/domoticz-AirHumidifier $ miiocli airhumidifierca1 --ip 192.168.1.20 --token b3026a0a55390cc375de32xxxxxxxxxx status
Power: off
Mode: OperationMode.Silent
Temperature: 18.9 °C
Humidity: 76 %
LED brightness: LedBrightness.Off
Buzzer: False
Child lock: False
Target humidity: 55 %
Trans level: None
Speed: 0
Depth: 125
Dry: False
Use time: 17823668
Hardware version: 0001
Button pressed: None

Could you please help me with the issue?

@syssi
Copy link
Collaborator

syssi commented Dec 27, 2019

Please create a new issue and provide a code example.

@lukaszantkowiak
Copy link

Please create a new issue and provide a code example.

Thanks, I've created #606.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants