Xiaomi mi wifi plug & air purifier

@1337hium @af950833 The issue is fixed. Please try again! :slight_smile:

it’s fixed :slight_smile: Thanks!

Which generation of the air purifier to you own?

Second one

Turning it on and off works fine? If yes, I will implement change modes next.

Yes, its works!!! That will be great!

THX, it works :slight_smile:

Also got the Purifier 2 and on/off works (for what i can see, i’m not home, but the App shows it too)

Could you do me a favour? Please click on the device and provide a screenshot which shows the current attributes. Thanks!

Hope this helps:

24 AM

25 AM

check from mine.
regards

Thanks for the screenshots. I missed the air quality index (aqi) which is available now. Please checkout the development branch as next step: https://github.com/syssi/xiaomi_airpurifier/commits/develop

Changing the OperationMode by the speed dropdown should be possible now.

50 AM

If i select a mode in the dropdown i get following error:

2017-08-29 10:52:37 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 140529548874080: Received {'id': 13, 'service_data': {'entity_id': 'fan.michus_air_purifier_2', 'speed': 'Silent'}, 'domain': 'fan', 'type': 'call_service', 'service': 'turn_on'}
2017-08-29 10:52:37 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=140530430124552-32, service_data=entity_id=fan.michus_air_purifier_2, speed=Silent, domain=fan, service=turn_on>
2017-08-29 10:52:37 DEBUG (Thread-3) [mirobo.protocol] Unable to decrypt, returning raw bytes.
2017-08-29 10:52:37 DEBUG (Thread-3) [mirobo.device] Got a response: Container:
    data = Container:
        length = 0
        offset1 = 32
        offset2 = 32
        value =  (total 0)
        data =  (total 0)
    header = Container:
        length = 16
        offset1 = 0
        offset2 = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 860
            serial = 48757
            ts = 1970-01-15 12:53:31
        data = !1\x00 \x00\x00\x00\x00\x03\\\xbeu\x00\x13*K (total 16)
    checksum = \xbc\x91\x848\x82 ?(/\xaf\xee\x82\xb5#\xd4\xfa (total 16)
2017-08-29 10:52:37 DEBUG (Thread-3) [mirobo.device] Discovered 860 48757 with ts: 1970-01-15 12:53:31, token: b'bc91843882203f282fafee82b523d4fa'
2017-08-29 10:52:37 DEBUG (Thread-3) [mirobo.device] 192.168.1.215:54321 >>: {'id': 11, 'params': ['on'], 'method': 'set_power'}
2017-08-29 10:52:37 DEBUG (Thread-3) [mirobo.device] 192.168.1.215:54321 (ts: 1970-01-15 12:53:31, id: 11) << {'id': 11, 'result': ['ok']}
2017-08-29 10:52:37 DEBUG (MainThread) [custom_components.fan.xiaomi_airpurifier] Response received from air purifier: ['ok']
2017-08-29 10:52:37 DEBUG (Thread-4) [mirobo.protocol] Unable to decrypt, returning raw bytes.
2017-08-29 10:52:37 DEBUG (Thread-4) [mirobo.device] Got a response: Container:
    data = Container:
        length = 0
        offset1 = 32
        offset2 = 32
        value =  (total 0)
        data =  (total 0)
    header = Container:
        length = 16
        offset1 = 0
        offset2 = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 860
            serial = 48757
            ts = 1970-01-15 12:53:31
        data = !1\x00 \x00\x00\x00\x00\x03\\\xbeu\x00\x13*K (total 16)
    checksum = \xbc\x91\x848\x82 ?(/\xaf\xee\x82\xb5#\xd4\xfa (total 16)

Ups! :slight_smile: I must think about it.

Could you check somethine in the mean time? Please enter the virtualenv of your home assistant installation f.e.

# applies to hassbian
su - homeassistant
source /srv/homeassistant/bin/activate

Now there should be a commandline tool available called “mirobo”. Please try to control the modes of the air purifier by

mirobo --ip 192.168.0.15 --token your-token raw_command set_mode '["auto"]')
mirobo --ip 192.168.0.15 --token your-token raw_command set_mode '["silent"]')
mirobo --ip 192.168.0.15 --token your-token raw_command set_mode '["favorite"]')
mirobo --ip 192.168.0.15 --token your-token raw_command set_mode '["idle"]')

Does it work or it’s returning the same error?

Works great:

(homeassistant) michu@hass:/home/homeassistant/.homeassistant$ mirobo --ip 192.168.1.215 --token bc91843882203f282fafee82b523d4fa raw_command set_mode '["auto"]'
Sending cmd set_mode with params ['auto']
['ok']

So just my component is buggy. :wink:

Doesn’t have to, my system is always special :stuck_out_tongue:

Maybe @pitoganzado can test it with the dev branch and check if he gets the same errors.

@syssi

2017-08-25 15:48:12 ERROR (MainThread) [miio.miio] got error when receiving: timed out 2017-08-25 15:48:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step result = next(coro) File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1025, in _event_to_service_call yield from service_handler.func(service_call) File “/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py”, line 67, in _learn_command ir_remote.send(“miIO.ir_learn”, {‘key’: str(key)}) File “/srv/homeassistant/lib/python3.4/site-packages/miio/miio.py”, line 128, in send data, addr = s.recvfrom(1024) socket.timeout: timed out 2017-08-25 15:48:13 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=1973561136-678, domain=mqtt, service=publish, service_data=topic=RPi3HA, payload={“event_type”: “call_service”, “event_data”: {“service_call_id”: “1973561136-677”, “domain”: “chuangmi”, “service”: “learn_command_192_168_1_197”, “service_data”: {}}}> 2017-08-25 15:48:13 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

Please create a new topic and describe your problem with one sentence. I know you are trying to use the chuangmi_ir implementation and their occurs a network error sometimes. :wink:

ok i’ll do…