Re: Xiaomi Air Purifier 2
Posted: Thursday 08 March 2018 17:36
I move this great work to the right forum: python
Great!!! works fine. thanks a lot!kofec wrote: ↑Thursday 08 March 2018 15:57 If you want you can try the script 'MyAir.py" from https://github.com/kofec/domoticz-AirPurifier
e.g:
pi@raspberrypi:~/domoticz/plugins/domoticz-AirPurifier $ ./MyAir.py 192.168.1.40 933c4c22df26adaec86d6fd788f5af72
<AirPurifierStatus power=on, aqi=9,average_aqi=8,temperature=21.1, humidity=31%,mode=OperationMode.Auto,led=True,led_brightness=LedBrightness.Bright,buzzer=True, child_lock=False,favorite_level=10,filter_life_remaining=53, filter_hours_used=1614, use_time=7632371, purify_volume=77517, motor_speed=355>
Nice plugin, thanks! I'm having a little hiccup though whenkofec wrote: ↑Friday 02 February 2018 14:55 I have created a plugin: https://github.com/kofec/domoticz-AirPurifier
Code: Select all
./MyAir.py 192.168.1.129 7d5474e308cf13f359373fd1c2b0e676 --debug
Code: Select all
2018-04-07 08:15:46.682 Error: (AirPurifier) failed to load 'plugin.py', Python Path used was '/home/osmc/domoticz/plugins/xiaomi-purifier/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-04-07 08:15:46.682 Error: (Purifier) Module Import failed, exception: 'ImportError'
2018-04-07 08:15:46.682 Error: (Purifier) Module Import failed: ' Name: miio'
2018-04-07 08:15:46.682 Error: (Purifier) Error Line details not available.
Can you help me with this?'/home/osmc/domoticz/plugins/xiaomi-purifier/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'
Code: Select all
pathOfPackages = '/home/osmc/.local/lib/python3.5/site-packages'
Code: Select all
2018-04-07 08:56:12.146 Error: Domoticz received fatal signal 11 !...
2018-04-07 08:56:12.148 Error: /home/osmc/domoticz/domoticz() [0x24f04c]
2018-04-07 08:56:12.148 Error: /home/osmc/domoticz/domoticz(_Z14signal_handleri+0x4c) [0x24f104]
2018-04-07 08:56:12.148 Error: /lib/arm-linux-gnueabihf/libc.so.6(+0x24fd0) [0x76c66fd0]
I need your help for Xiaomi pm2.5 sensor; The Python Plugin doesn't work @ home.ben53252642 wrote: ↑Wednesday 18 January 2017 18:55 8) For those who want to load the Temperature, Humidity and Aqi (pm2.5 estimate) into Domoticz sensors, below is a updatedomoticz.sh bash script:Code: Select all
#!/bin/bash while true; do # Get the data data=$(node airpurifier.js 192.168.0.240 status) # Sort it temperature=$(echo "$data" | grep "temperature" | sed -e s/[^0-9.]//g) humidity=$(echo "$data" | grep "humidity" | sed -e s/[^0-9.%]//g) aqi=$(echo "$data" | grep "aqi" | sed -e s/[^0-9.]//g) # Load it into Domoticz curl -s "http://USERNAME:[email protected]/json.htm?type=command¶m=udevice&idx=607&nvalue=0&svalue=${temperature};${humidity};0" curl -s "http://USERNAME:[email protected]/json.htm?type=command¶m=udevice&idx=599&svalue=${aqi}" sleep 60 done
Code: Select all
{ power: true, aqi: 14, batteryLevel: 100, charging: true }
Code: Select all
aqi=$(echo "$data" | grep "aqi" | sed -e s/[^0-9.]//g)
Code: Select all
aqi=$(echo "$data" | grep -Po ' aqi=\K[^,]+')
2) Install miIO Device Library: npm install --save miio
Code: Select all
npm WARN engine [email protected]: wanted: {"node":">=6.6.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.6.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
3) Install miio command line utility: npm install -g miio
Code: Select all
npm WARN engine [email protected]: wanted: {"node":">=6.6.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.6.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})
4) Run this command to discover and sync the key from your Air Purifier: miio --discover --sync
Code: Select all
miio --discover --sync
Code: Select all
2018-08-24 23:40:16.608 Error: (AirPurifier) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-AirPurifier/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-08-24 23:40:16.609 Error: (Oczyszczacz) Module Import failed, exception: 'ImportError'
2018-08-24 23:40:16.609 Error: (Oczyszczacz) Module Import failed: ' Name: miio'
2018-08-24 23:40:16.609 Error: (Oczyszczacz) Error Line details not available.
Code: Select all
./MyAir.py 192.168.1.4 e8c60b26d83ca76c9b94ee066f4ccf23 --debug
Namespace(IPaddress='192.168.1.4', debug=True, favoriteLevel=None, mode=None, power=None, token='e8c60b26d83ca76c9b94ee066f4ccf23')
<AirPurifierStatus power=on, aqi=10, average_aqi=8, temperature=26.6, humidity=59%, mode=OperationMode.Auto, led=True, led_brightness=LedBrightness.Dim, illuminance=None, buzzer=False, child_lock=False, favorite_level=10, filter_life_remaining=6, filter_hours_used=3274, use_time=11784415, purify_volume=130722, motor_speed=344, motor2_speed=None, volume=None, filter_rfid_product_id=None, filter_rfid_tag=None, filter_type=None, learn_mode=False, sleep_mode=None, sleep_time=None, sleep_mode_learn_count=None, extra_features=0, turbo_mode_supported=False, auto_detect=None, button_pressed=None>
Code: Select all
2019-01-04 22:53:49.032 Status: (Oczyszczacz) Entering work loop.
2019-01-04 22:53:49.032 Status: (Oczyszczacz) Initialized version 0.1.1, author 'kofec'
Code: Select all
./MyAir.py 192.168.0.45 39afd28889c854f90e51bd525c0bccbe --power OFF
<AirPurifierStatus power=on, aqi=41, average_aqi=23, temperature=13.9, humidity=49%, mode=OperationMode.Silent, led=True, led_brightness=None, illuminance=200, buzzer=None, child_lock=False, favorite_level=17, filter_life_remaining=87, filter_hours_used=451, use_time=None, purify_volume=None, motor_speed=299, motor2_speed=647, volume=50, filter_rfid_product_id=0:0:30:33, filter_rfid_tag=80:5c:ac:82:b0:ca:4, filter_type=FilterType.Regular, learn_mode=False, sleep_mode=None, sleep_time=None, sleep_mode_learn_count=None, extra_features=0, turbo_mode_supported=False, auto_detect=None, button_pressed=None>
Code: Select all
2019-04-17 19:14:46.209 Status: User: Admin initiated a switch command (97/XiaomiAir - Power/On)
2019-04-17 19:14:46.248 Error: (XiaomiAir) 'onCommand' failed 'FileNotFoundError'.
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 581 in C:\Program Files (x86)\Domoticz\plugins\domoticz-AirPurifier-master\plugin.py, function onCommand
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 329 in C:\Program Files (x86)\Domoticz\plugins\domoticz-AirPurifier-master\plugin.py, function onCommand
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 626 in C:\Program Files (x86)\Python35-32\Lib\subprocess.py, function check_output
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 693 in C:\Program Files (x86)\Python35-32\Lib\subprocess.py, function run
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 972 in C:\Program Files (x86)\Python35-32\Lib\subprocess.py, function __init__
2019-04-17 19:14:46.248 Error: (XiaomiAir) ----> Line 1239 in C:\Program Files (x86)\Python35-32\Lib\subprocess.py, function _execute_child
Code: Select all
2019-05-05 12:38:11.213 Status: Domoticz V4.10686 (c)2012-2019 GizMoCuz
2019-05-05 12:38:11.213 Status: Build Hash: f7fc1571, Date: 2019-05-04 13:17:04
2019-05-05 12:38:11.213 Status: Startup Path: /home/pi/domoticz/
2019-05-05 12:38:11.359 Status: PluginSystem: Started, Python version '3.5.3'.
2019-05-05 12:38:11.368 Status: WebServer(HTTP) started on address: :: with port 8888
2019-05-05 12:38:11.373 Status: WebServer(SSL) started on address: :: with port 443
2019-05-05 12:38:11.375 Status: Camera: settings (re)loaded
2019-05-05 12:38:11.412 Status: TCPServer: shared server started...
2019-05-05 12:38:11.412 Status: RxQueue: queue worker started...
2019-05-05 12:38:13.413 Status: RFXCOM: Worker started...
2019-05-05 12:38:13.413 Status: XiaomiGateway (ID=3): Delaying worker startup...
2019-05-05 12:38:14.992
2019-05-05 12:38:14.416 Status: RFXCOM: Using serial port: /dev/ttyUSB0
2019-05-05 12:38:15.068 subtype = Interface Response
2019-05-05 12:38:15.068 Sequence nbr = 2
2019-05-05 12:38:15.068 response on cmnd = Get Status
2019-05-05 12:38:15.068 Transceiver type = 433.92MHz
2019-05-05 12:38:15.068 Firmware version = 1025
2019-05-05 12:38:15.068 Firmware type = Ext
2019-05-05 12:38:15.068 Hardware version = 1.3
2019-05-05 12:38:15.068 Undec off
2019-05-05 12:38:15.068 X10 enabled
2019-05-05 12:38:15.068 ARC enabled
2019-05-05 12:38:15.068 AC enabled
2019-05-05 12:38:15.068 HomeEasy EU enabled
2019-05-05 12:38:15.068 Meiantech/Atlantic disabled
2019-05-05 12:38:15.068 Oregon Scientific enabled
2019-05-05 12:38:15.068 ATI/Cartelectronic disabled
2019-05-05 12:38:15.068 Visonic disabled
2019-05-05 12:38:15.068 Mertik disabled
2019-05-05 12:38:15.068 AD disabled
2019-05-05 12:38:15.068 Hideki enabled
2019-05-05 12:38:15.068 La Crosse enabled
2019-05-05 12:38:15.068 Legrand disabled
2019-05-05 12:38:15.068 MSG4Reserved5 disabled
2019-05-05 12:38:15.068 BlindsT0 disabled
2019-05-05 12:38:15.068 BlindsT1 disabled
2019-05-05 12:38:15.068 AE disabled
2019-05-05 12:38:15.068 RUBiCSON disabled
2019-05-05 12:38:15.068 FineOffset disabled
2019-05-05 12:38:15.068 Lighting4 disabled
2019-05-05 12:38:15.068 Conrad RSL disabled
2019-05-05 12:38:15.068 ByronSX disabled
2019-05-05 12:38:15.068 IMAGINTRONIX disabled
2019-05-05 12:38:15.068 KEELOQ disabled
2019-05-05 12:38:15.068 Home Confort disabled
2019-05-05 12:38:18.461 (Xiaomi) Temp + Humidity + Baro (Buiten TempHumBaro)
2019-05-05 12:38:18.465 (Xiaomi) Temp + Humidity + Baro (Jane TempHumBaro)
2019-05-05 12:38:18.467 (Xiaomi) Lux (Aqara Motion Sensor)
2019-05-05 12:38:18.470 (Xiaomi) Temp + Humidity + Baro (Schuur TempHumBaro)
2019-05-05 12:38:18.473 (Xiaomi) Temp + Humidity + Baro (Badkamer TempHumBaro)
2019-05-05 12:38:18.475 (Xiaomi) Temp + Humidity + Baro (Slaapkamer TempHumBaro)
2019-05-05 12:38:18.414 Status: XiaomiGateway (ID=3): Selected as main Gateway
2019-05-05 12:38:18.414 Status: XiaomiGateway (ID=3): Worker started...
2019-05-05 12:38:18.414 Status: (Beneden luchtreiniger) Started.
2019-05-05 12:38:18.414 Status: (Kantoor luchtreiniger) Started.
2019-05-05 12:38:18.414 Status: XiaomiGateway (ID=3): Using 192.168.2.32 for local IP address.
2019-05-05 12:38:18.415 Status: EventSystem: reset all events...
2019-05-05 12:38:18.416 Status: EventSystem: reset all device statuses...
2019-05-05 12:38:18.439 Status: XiaomiGateway: RGB Gateway Detected
2019-05-05 12:38:18.609 Status: Python EventSystem: Initalizing event module.
2019-05-05 12:38:18.609 Status: EventSystem: Started
2019-05-05 12:38:18.610 Status: EventSystem: Queue thread started...
2019-05-05 12:38:18.755 Status: PluginSystem: Entering work loop.
2019-05-05 12:38:18.980 Status: (Beneden luchtreiniger) Entering work loop.
2019-05-05 12:38:18.980 Status: (Beneden luchtreiniger) Initialized version 0.1.1, author 'kofec'
2019-05-05 12:38:19.151 (Beneden luchtreiniger) Debug logging mask set to: NONE
2019-05-05 12:38:19.151 (Beneden luchtreiniger) Device UNIT_MODE_CONTROL with id 10 exist
2019-05-05 12:38:19.151 (Beneden luchtreiniger) Device UNIT_MODE_CONTROL with id 11 exist
2019-05-05 12:38:19.151 (Beneden luchtreiniger) Device UNIT_MOTOR_SPEED_FAVORITE with id 12 exist
2019-05-05 12:38:19.147 Status: (Kantoor luchtreiniger) Entering work loop.
2019-05-05 12:38:19.147 Status: (Kantoor luchtreiniger) Initialized version 0.1.1, author 'kofec'
2019-05-05 12:38:20.600 (Beneden luchtreiniger) Starting device update
2019-05-05 12:38:20.600 (Beneden luchtreiniger) Update unit=1; nValue=0; sValue=37
2019-05-05 12:38:20.604 (Beneden luchtreiniger) Update unit=2; nValue=1; sValue=Great air quality
2019-05-05 12:38:20.605 (Beneden luchtreiniger) Update unit=3; nValue=0; sValue=18.7
2019-05-05 12:38:20.606 (Beneden luchtreiniger) Update unit=4; nValue=51; sValue=0
2019-05-05 12:38:20.606 (Beneden luchtreiniger) Update unit=5; nValue=0; sValue=348
2019-05-05 12:38:20.607 (Beneden luchtreiniger) Update unit=6; nValue=0; sValue=8
2019-05-05 12:38:20.613 (Kantoor luchtreiniger) Debug logging mask set to: NONE
2019-05-05 12:38:20.613 (Kantoor luchtreiniger) Device UNIT_MODE_CONTROL with id 10 exist
2019-05-05 12:38:20.613 (Kantoor luchtreiniger) Device UNIT_MODE_CONTROL with id 11 exist
2019-05-05 12:38:20.613 (Kantoor luchtreiniger) Device UNIT_MOTOR_SPEED_FAVORITE with id 12 exist
2019-05-05 12:38:22.057 (Kantoor luchtreiniger) Starting device update
2019-05-05 12:38:22.058 (Kantoor luchtreiniger) Update unit=1; nValue=0; sValue=48
2019-05-05 12:38:22.061 (Kantoor luchtreiniger) Update unit=2; nValue=1; sValue=Great air quality
2019-05-05 12:38:22.062 (Kantoor luchtreiniger) Update unit=3; nValue=0; sValue=19.3
2019-05-05 12:38:22.063 (Kantoor luchtreiniger) Update unit=4; nValue=44; sValue=0
2019-05-05 12:38:22.063 (Kantoor luchtreiniger) Update unit=5; nValue=0; sValue=346
2019-05-05 12:38:22.066 (Kantoor luchtreiniger) Update unit=6; nValue=0; sValue=8