Xiaomi Air Purifier 2

Python and python framework

Moderator: leecollings

User avatar
householder
Posts: 5
Joined: Monday 14 January 2019 5:26
Target OS: Windows
Domoticz version: last
Location: Stockholm
Contact:

Re: Xiaomi Air Purifier 2

Post by householder »

Hey guys,

What do I need to put on Domoticz my device? I'm not a coding guru, but can handle some tech tips!

Thank you in advance.
Pavlo
Posts: 1
Joined: Tuesday 26 November 2019 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by Pavlo »

Hi everyone,

I'm using this "MyAir.py" with IP and Token. And it works fine.
In Domoticz I created 3 switches:
- Air Purifier 2S - Power
- Air Purifier 2S - Source
- Air Purifier 2S - Fan Favorite level

And my question: how to add command in "Air Purifier 2S - Power" for ON and OFF Air Purifier in action section ?

Thanks for helping
philips
Posts: 12
Joined: Friday 07 February 2020 15:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Poland
Contact:

Re: Xiaomi Air Purifier 2

Post by philips »

Hi,

I'm trying to get this working without success.
I'm installing python-miio:

Code: Select all

pi@Smarticz:~/domoticz/plugins/domoticz-AirPurifier $ pip3 install -U python-miio
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-miio
  Using cached https://files.pythonhosted.org/packages/ef/b1/2d4c7b9092744049f21ff0b02e9d01720db9367006bbff68077cc1e6b8b7/python_miio-0.4.8-py3-none-any.whl
Requirement already satisfied, skipping upgrade: cryptography in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (2.1.3)
Requirement already satisfied, skipping upgrade: construct in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (2.8.17)
Requirement already satisfied, skipping upgrade: attrs in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (17.2.0)
Requirement already satisfied, skipping upgrade: zeroconf in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (0.24.0)
Requirement already satisfied, skipping upgrade: pytz in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (2019.3)
Requirement already satisfied, skipping upgrade: netifaces in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (0.10.9)
Requirement already satisfied, skipping upgrade: tqdm in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (4.40.2)
Requirement already satisfied, skipping upgrade: click>=7 in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (7.0)
Requirement already satisfied, skipping upgrade: appdirs in /home/pi/.local/lib/python3.7/site-packages (from python-miio) (1.4.3)
Requirement already satisfied, skipping upgrade: idna>=2.1 in /usr/lib/python3/dist-packages (from cryptography->python-miio) (2.6)
Requirement already satisfied, skipping upgrade: six>=1.4.1 in /home/pi/.local/lib/python3.7/site-packages (from cryptography->python-miio) (1.11.0)
Requirement already satisfied, skipping upgrade: cffi>=1.7; platform_python_implementation != "PyPy" in /home/pi/.local/lib/python3.7/site-packages (from cryptography->python-miio) (1.11.2)
Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /home/pi/.local/lib/python3.7/site-packages (from cryptography->python-miio) (0.23.0)
Requirement already satisfied, skipping upgrade: ifaddr in /home/pi/.local/lib/python3.7/site-packages (from zeroconf->python-miio) (0.1.6)
Requirement already satisfied, skipping upgrade: pycparser in /home/pi/.local/lib/python3.7/site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->python-miio) (2.18)
Installing collected packages: python-miio
Successfully installed python-miio-0.4.8
so I have python 3.7 with miio-0.4.8 as you can see.
I'm installing it as PI user, not sudo or root, as it is in all docs specified (or should it be as root ?)
Running ./MyAir.py gives me :

Code: Select all

pi@Smarticz:~/domoticz/plugins/domoticz-AirPurifier $ ./MyAir.py 192.168.1.36 56729500173b73ab57b63c07ebeedab1 --debug
Traceback (most recent call last):
  File "./MyAir.py", line 11, in <module>
    import miio.airpurifier
  File "/home/pi/.local/lib/python3.7/site-packages/miio/__init__.py", line 2, in <module>
    from miio.airconditioningcompanion import (
  File "/home/pi/.local/lib/python3.7/site-packages/miio/airconditioningcompanion.py", line 8, in <module>
    from .device import Device, DeviceException
  File "/home/pi/.local/lib/python3.7/site-packages/miio/device.py", line 14, in <module>
    from .protocol import Message
  File "/home/pi/.local/lib/python3.7/site-packages/miio/protocol.py", line 206, in <module>
    Const(0x2131, Int16ub),
  File "/home/pi/.local/lib/python3.7/site-packages/construct/core.py", line 1929, in __init__
    super(Const, self).__init__(subcon)
  File "/home/pi/.local/lib/python3.7/site-packages/construct/core.py", line 288, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct fiel
I do have all the prerequisites: libffi-dev libssl-dev, setuptools etc.
and the installed plugin version is :

Code: Select all

git clone https://github.com/kofec/domoticz-AirPurifier
and of course it does not work in Domoticz.

What can be wrong ?
Raspberry Pi 4 2GB
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest