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

feat: air-purifier 3 support #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kstasik
Copy link

@kstasik kstasik commented Jan 25, 2020

correct me if im wrong but this project looks dead. I created PR some maybe someone find this code useful. Credits to rytilahti/python-miio#543 (comment)

@Shaun-R
Copy link

Shaun-R commented Jan 26, 2020

This is amazing, thank you for your work. I installed this and /clauzewitz/homebridge-xiaomi-purifier, and my Air Purifier 3H appears in HomeKit with current status.

I can then issue one command, e.g. power on, which works - but no response is returned to HomeKit and the whole accessory goes to "No response" state.

Further, the Buzzer and LED options do not appear to work at all. They return "On" even when actual state is "Off"

Would you suggest using a different version/pull of homebridge-xiaomi-purifier?

EDIT: Homebridge throws errors like this:
[1/26/2020, 1:56:16 PM] [MiAirPurifierPlatform] [MiAirPurifierPlatform][ERROR]MiAirPurifier3BuzzerSwitchAccessory - Mute - getBuzzerState Error: Error: busy.

I have Homebridge config.js like so:
{ "accessory": "MiAirPurifier", "name": "Air Purifier", "ip": "192.168.1.55", "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "showTemperature": true, "showHumidity": true, "showAirQuality": true, "enableLED": false, "enableBuzzer": false }

Should the "accessory" be "MiAirPurifier3" or similar?

@kstasik
Copy link
Author

kstasik commented Jan 26, 2020

I used original: https://github.com/seikan/homebridge-mi-air-purifier

      {
            "accessory": "MiAirPurifier",
            "name": "Air Purifier 3 Living Room",

            "ip": "ip address",
            "token": "value",

            "showTemperature": true,
            "showHumidity": true,
            "showAirQuality": true
        }

I used this video to retrieve token: https://www.youtube.com/watch?v=g4pa7sesTzY

I found out that my device code is: zhimi.airpurifier.mb3 ( i bought device in europe )

I used this simple php script to decode token and find model name:

<?php

$filename = 'NAME_OF_FILE_mihome.sqlite';

$db = new PDO('sqlite:'.$filename);

$db->setAttribute(PDO::ATTR_ERRMODE,
                        PDO::ERRMODE_EXCEPTION);

$result = $db->query('SELECT ZNAME, ZMODEL, ZLOCALIP, ZTOKEN FROM ZDEVICE');

foreach($result as $r){
    print_r($r);

    echo decrypt_openssl($r['ZTOKEN']);
    echo PHP_EOL;
}

function decrypt_openssl($raw) {
    $key = str_repeat('0', 32);
    $key = hex2bin($key);
    $raw = hex2bin($raw);

	return openssl_decrypt($raw, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
}

I think you can have different model name (maybe zhimi.airpurifier.ma4) and you should add correct mapping here:

https://github.com/aholstenson/miio/pull/277/files#diff-082a0303463873190e3974467cfb3d0fR38

@huongminh
Copy link

correct me if im wrong but this project looks dead. I created PR some maybe someone find this code useful. Credits to rytilahti/python-miio#543 (comment)

Thank you for your great work! Now my air purifier 3 works like a charm!

@bnowak
Copy link

bnowak commented Dec 18, 2021

Geat work @kstasik, it should be merged ASAP 💪

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

Successfully merging this pull request may close these issues.

4 participants