Xiaomi Air Purifier 2

Python and python framework
mozo78
Posts: 18
Joined: Friday 09 June 2017 6:29
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by mozo78 » Monday 19 June 2017 9:15

Julz wrote:Hi all,
I'm having trouble getting the bash script to feed updates via JSON to my Raspberry Pi. I can trigger the bash script manually and it seems to update the temperature sensor and PM2.5 sensor values the first time but then the temperature sensor updates to 0.0C and the PM2.5 sensor doesn't update again. I'm pretty sure I've set up the script to trigger at boot via a call to my 'startup.sh' script in my /etc/rc.local but after bootup is complete, doing a 'screen -list' doesn't show any sessions running unlike when I manually execute my startup.sh. Any suggestions?

TIA!
I had the same problem, but this helped me:

http://raspberrypituts.com/raspberry-pi ... planation/

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by ToneStrife » Monday 10 July 2017 12:52

I have miiio working, I want to use the Wifi plugs.
I have read about power-plug and power-switch in the miio wiki but I don't know which commando should I use.
Anyone with an adapted script for the plugs can help me? I have the IPs but after that I'm a little bit stucked.

DAVIZINHO
Posts: 198
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi Air Purifier 2

Post by DAVIZINHO » Sunday 27 August 2017 18:02

Hello,
I have a synology NAS with Node.js v4 because i don´t know how to upgrade to v6 :-(

I run this comand: "miio --discover --sync" and obtain this error:
[code]
admin@synology:~$ miio --discover --sync
/usr/local/lib/node_modules/miio/cli/index.js:10
const { Browser, Devices } = require('../lib/discovery');
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:140:18)
at node.js:1043:3
admin@synology:~$
[/code]

any idea??
thanks a lot and sorry for my poor english :-(

DAVIZINHO
Posts: 198
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi Air Purifier 2

Post by DAVIZINHO » Tuesday 19 September 2017 11:23

hello,
Its imposible to me make this works in:
- synology: I cant upgrade the node.js :-(
- raspberry pi zero: the miio not works :-(

But it works perfect for me in a raspberry pi2 with raspbian!! :-D

Andree
Posts: 80
Joined: Wednesday 07 June 2017 11:19
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by Andree » Wednesday 04 October 2017 10:47

hi,there's a way to making this work on Windows?

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Sunday 22 October 2017 20:16

Hello,

I'm having some problems :
This works :
/var/domoticz/scripts/external/xiaomiAirPurifierControl.sh 192.168.0.55 off
sudo /var/domoticz/scripts/external/xiaomiAirPurifierControl.sh 192.168.0.55 off

This does not work :
Pushing the button on Domoticz
I don't have any errors thrown in the log.
Capture d’écran 2017-10-22 à 20.13.53.png
Capture d’écran 2017-10-22 à 20.13.53.png (98.92 KiB) Viewed 3290 times
Capture d’écran 2017-10-22 à 20.13.28.png
Capture d’écran 2017-10-22 à 20.13.28.png (14.76 KiB) Viewed 3290 times
Any ideas ?

Thanks for your help :)
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Tuesday 24 October 2017 22:45

New problem for me :

Domoticz:/var/domoticz/scripts/external/xiaomiAirPurifier.js 192.168.0.55 power off
Sending Power off command
(node:21561) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token o in JSON at position 0

No idea what to do with this.

Any advise ?
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Wednesday 25 October 2017 6:41

All solved
tho071088 wrote:
Tuesday 24 October 2017 22:45
New problem for me :

Domoticz:/var/domoticz/scripts/external/xiaomiAirPurifier.js 192.168.0.55 power off
Sending Power off command
(node:21561) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token o in JSON at position 0

No idea what to do with this.

Any advise ?
This one was my fault, wrong command sent.

For the other one, I had to make the require this way :
Not working :
const miio = require('miio');
Working :
const miio = require('../../../../usr/lib/node_modules/miio');
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

MsbS
Posts: 42
Joined: Friday 19 May 2017 14:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by MsbS » Wednesday 25 October 2017 14:36

tho071088 wrote:
Wednesday 25 October 2017 6:41
For the other one, I had to make the require this way :
Not working :
const miio = require('miio');
Working :
const miio = require('../../../../usr/lib/node_modules/miio');
Could you replace the relative path ('../..') with a single / ? Basically :

const miio = require('/usr/lib/node_modules/miio');


For me the script from the first post does nothing - I ran the miio sync command (got no output), when I run the examples with 'node airpurifier.js IP command', nothing happens.

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Wednesday 25 October 2017 14:42

MsbS wrote:
Wednesday 25 October 2017 14:36
tho071088 wrote:
Wednesday 25 October 2017 6:41
For the other one, I had to make the require this way :
Not working :
const miio = require('miio');
Working :
const miio = require('../../../../usr/lib/node_modules/miio');
Could you replace the relative path ('../..') with a single / ? Basically :

const miio = require('/usr/lib/node_modules/miio');


For me the script from the first post does nothing - I ran the miio sync command (got no output), when I run the examples with 'node airpurifier.js IP command', nothing happens.
No, just a / will not work, already tried

If nothing is displayed, you have to add some lines to the JS file.

process.on('uncaughtException', function (error) {
console.log(error.stack);
});
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

Andree
Posts: 80
Joined: Wednesday 07 June 2017 11:19
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by Andree » Wednesday 25 October 2017 16:01

Sorry, there is no way for Windows?

MsbS
Posts: 42
Joined: Friday 19 May 2017 14:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by MsbS » Thursday 26 October 2017 9:31

tho071088 wrote:
Wednesday 25 October 2017 14:42
If nothing is displayed, you have to add some lines to the JS file.

process.on('uncaughtException', function (error) {
console.log(error.stack);
});
Unfortunately, this did not help. I think there's something wrong with node or with miio in my case.

- when I tried 'npm install --save miio', I got a whole lot of errors.
- doing this with sudo ('sudo npm install --save miio') worked, but I still got warning about the version of node:

Code: Select all

wanted: {"node":">=6.0.0"} (current: {"node":"4.8.2","npm":"1.4.21"})
- When I run 'miio --discover --sync', it gives me no output at all, where can I find a logfile to check what went wrong?

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Thursday 26 October 2017 9:47

MsbS wrote:
Thursday 26 October 2017 9:31
tho071088 wrote:
Wednesday 25 October 2017 14:42
If nothing is displayed, you have to add some lines to the JS file.

process.on('uncaughtException', function (error) {
console.log(error.stack);
});
Unfortunately, this did not help. I think there's something wrong with node or with miio in my case.

- when I tried 'npm install --save miio', I got a whole lot of errors.
- doing this with sudo ('sudo npm install --save miio') worked, but I still got warning about the version of node:

Code: Select all

wanted: {"node":">=6.0.0"} (current: {"node":"4.8.2","npm":"1.4.21"})
- When I run 'miio --discover --sync', it gives me no output at all, where can I find a logfile to check what went wrong?
You have to update node a new version.

Try
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install node

Are you on Raspbian Jessie ?
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

MsbS
Posts: 42
Joined: Friday 19 May 2017 14:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by MsbS » Thursday 26 October 2017 10:17

tho071088 wrote:
Thursday 26 October 2017 9:47
You have to update node a new version.

Try
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install node

Are you on Raspbian Jessie ?
I'm on Raspbian Stretch - the newer one. Did update, upgrade, install. I get: 'node is already the newest version (0.3.2-7.4).'

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Thursday 26 October 2017 10:35

MsbS wrote:
Thursday 26 October 2017 10:17
tho071088 wrote:
Thursday 26 October 2017 9:47
You have to update node a new version.

Try
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install node

Are you on Raspbian Jessie ?
I'm on Raspbian Stretch - the newer one. Did update, upgrade, install. I get: 'node is already the newest version (0.3.2-7.4).'
I'm on Jessie and node 6, there is maybe an issue with miio and node 7.
This is outside of my skills, sorry.
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

MsbS
Posts: 42
Joined: Friday 19 May 2017 14:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by MsbS » Thursday 26 October 2017 13:00

OK, I think I have this sorted out. I'll leave it here for others who can be struggling.

The key was to install the correct version of nodejs, as per this page:
https://nodejs.org/en/download/package- ... tributions

So, running:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

DAVIZINHO
Posts: 198
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi Air Purifier 2

Post by DAVIZINHO » Friday 03 November 2017 20:17

hello.
what kind of virtual sensors you create for aqi?
i can obtain the aqi data but not works the update to domoticz comand. allways 0 :-(

curl -s "http://192.168.1.4:8080/json.htm?type=c ... alue=${aqi}"

any idea?

tho071088
Posts: 24
Joined: Monday 24 April 2017 23:03
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Gerstheim, France
Contact:

Re: Xiaomi Air Purifier 2

Post by tho071088 » Friday 03 November 2017 21:44

DAVIZINHO wrote:
Friday 03 November 2017 20:17
hello.
what kind of virtual sensors you create for aqi?
i can obtain the aqi data but not works the update to domoticz comand. allways 0 :-(

curl -s "http://192.168.1.4:8080/json.htm?type=c ... alue=${aqi}"

any idea?
Custom Sensor type worked for me
Domoticz Beta on Rasbperry Pi 3
RFLink / YeeLight / Xiaomi Devices / 433MHz / SonOff via MQTT

DAVIZINHO
Posts: 198
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi Air Purifier 2

Post by DAVIZINHO » Friday 03 November 2017 21:49

tho071088 wrote:
Friday 03 November 2017 21:44
DAVIZINHO wrote:
Friday 03 November 2017 20:17
hello.
what kind of virtual sensors you create for aqi?
i can obtain the aqi data but not works the update to domoticz comand. allways 0 :-(

curl -s "http://192.168.1.4:8080/json.htm?type=c ... alue=${aqi}"

any idea?
Custom Sensor type worked for me
Works! thanks!

MsbS
Posts: 42
Joined: Friday 19 May 2017 14:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Air Purifier 2

Post by MsbS » Monday 06 November 2017 12:29

My Purifier (using the script from this thread) sometimes sends strange values to the T+H IDX (temperature 0, humidity 0). Did anyone have similar issue? For now, I added an 'if', which does not send the 0/0 data, but maybe there is a better fix.
The aqi reading is correct, no strange values (unless the reading of 10 aqi means broken data - I get that a lot).

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests