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

Air Purifier zhimi.airpurifier.m1 set_mode isn't working #436

Closed
krotoniec opened this issue Dec 12, 2018 · 2 comments
Closed

Air Purifier zhimi.airpurifier.m1 set_mode isn't working #436

krotoniec opened this issue Dec 12, 2018 · 2 comments

Comments

@krotoniec
Copy link

krotoniec commented Dec 12, 2018

Hello,
I was playing with miio library and noticed that set_mode doesn't work:
from miio import*
pur = AirPurifier(ip='192.168.2.13', token="6106c6f3fa4357a1eacacc324685ac9a")
pur.set_mode(OperationMode.Silent)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'OperationMode' is not defined

Am I missing something?

@syssi
Copy link
Collaborator

syssi commented Dec 12, 2018

You should import the OperationMode class of the air purifier:

$ grep "class OperationMode" miio/*.py
miio/airconditioningcompanion.py:class OperationMode(enum.Enum):                                                                                                                                                                               
miio/airfresh.py:class OperationMode(enum.Enum):                                                                                                                                                                                               
miio/airhumidifier.py:class OperationMode(enum.Enum):                                                                                                                                                                                          
miio/airpurifier.py:class OperationMode(enum.Enum):                                                                                                                                                                                            
miio/cooker.py:class OperationMode(enum.Enum): 

@krotoniec
Copy link
Author

Worked like a charm, Thanks!
from miio import*
from miio.airpurifier import AirPurifier, OperationMode
pur = AirPurifier(ip='192.168.2.120', token='1e0e11653f345434235345438e5435')
pur.set_mode(OperationMode.Auto)
['ok']

@syssi syssi closed this as completed Dec 13, 2018
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

2 participants