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

Control Air purifier and Humidifier? #177

Closed
BerraKode opened this issue Jan 24, 2018 · 5 comments
Closed

Control Air purifier and Humidifier? #177

BerraKode opened this issue Jan 24, 2018 · 5 comments

Comments

@BerraKode
Copy link

Hello
First of all I've got the mirobo working and love it!

However I'm unsure how to get the air purifier and humidifier to work. I see the specific python files for them in the miio folder but when I try to import them into my own python file I get all kinds of errors. How do I control those two devices?

Thanks in advance and thank you for all your hard work!!

Best wishes - BerraKode

@BerraKode BerraKode changed the title Air purifier and humidifier with python commands? Control Air purifier and Humidifier? Jan 24, 2018
@rytilahti
Copy link
Owner

It would help if you'd describe what kind of errors you are getting. But I suppose something like this should work:

from miio import AirPurifier, AirHumidifier

airp = AirPurifier(ip, token)
print(airp.info())

airh = AirHumidifer(ip, token)
print(airh.info())

or you can also try to access them with the help of Discovery class (which will construct you a corresponding device objects).

@BerraKode
Copy link
Author

BerraKode commented Jan 24, 2018

I don't have the airpurifier and humidifier yet so I'm trying out on my vacuum. This is what I get:


pi@HomeController:/usr/local/lib/python3.4/dist-packages/miio$ python test.py
Traceback (most recent call last):
File "test.py", line 1, in
from miio import Vacuum
ImportError: No module named miio


I guess my problem is I don't know which folder to put the python file. Or does this mean my system don't have the miio package installed? Thanks for your patience!

(mirobo works flawlessly so at least python-miio was installed correctly I guess)

@BerraKode
Copy link
Author

and if I try to "import vacuum" instead it gives me this:


Traceback (most recent call last):
File "test.py", line 1, in
import vacuum
File "/usr/local/lib/python3.4/dist-packages/miio/vacuum.py", line 36
def init(self, ip: str, token: str = None, start_id: int = 0,
^
SyntaxError: invalid syntax


@BerraKode
Copy link
Author

omg I got it working!!!! I was using wrong version of python (have some applications that need python 2 lol). Thanks!!!! Now Im gonna buy humidifier and airpurifier for sure!!

@rytilahti
Copy link
Owner

Glad to hear you got it working! You should get used for virtual environments when working with python, see https://realpython.com/blog/python/python-virtual-environments-a-primer/ , and more importantly you should not keep your scripts under any distribution directory (like inside dist-packages nor miio). I think we can close this issue now.

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