nt0xa / homebridge-mi-humidifier

A Xiaomi Mi humidifier plugin for Homebridge
MIT License
64 stars 24 forks source link

Fail to get device properties. SocketError: Timeout #103

Closed raulchen closed 2 years ago

raulchen commented 2 years ago

I kept getting the following error when setting up this plugin with my Mijia Smart Sterilization Humidifier S. Although it says SocketError, I can confirm that the IP is reachable with ping. I also tried resetting the token, but no luck.

[11/27/2021, 9:28:01 PM] [MiHumidifier] [192.168.2.33] Fail to get device properties. SocketError: Timeout

Here are the debug logs. There are some errors. I’m not sure if they are relative.

[11/27/2021, 9:26:47 PM] [MiHumidifier] [192.168.2.33] Getting property "OnOff_State"
[11/27/2021, 9:26:47 PM] [MiHumidifier] [192.168.2.33] Getting property "OnOff_State"
[11/27/2021, 9:26:47 PM] [MiHumidifier] [192.168.2.33] Getting property "Humidity_Value"
[11/27/2021, 9:26:47 PM] [homebridge-mi-humidifier] This plugin generated a warning from the characteristic 'Current Relative Humidity': characteristic value expected valid finite number and received "undefined" (undefined). See https://git.io/JtMGR for more info.
[11/27/2021, 9:26:47 PM] [homebridge-mi-humidifier] Error: 
    at CurrentRelativeHumidity.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2074:105)
    at CurrentRelativeHumidity.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1967:16)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1569:24
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:9:18
    at BaseHumidifier.getProp (/homebridge/node_modules/homebridge-mi-humidifier/src/devices/humidifier.ts:237:5)
    at CurrentRelativeHumidity.<anonymous> (/homebridge/node_modules/homebridge-mi-humidifier/src/devices/humidifier.ts:191:14)
    at CurrentRelativeHumidity.emit (events.js:400:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1544:14
    at new Promise (<anonymous>)
    at CurrentRelativeHumidity.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1542:12)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at CurrentRelativeHumidity.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:656:38)
[11/27/2021, 9:26:47 PM] [MiHumidifier] [192.168.2.33] Getting property "Humidifier_Gear"
[11/27/2021, 9:26:47 PM] [MiHumidifier] [192.168.2.33] Getting property "waterstatus"
[11/27/2021, 9:26:47 PM] [homebridge-mi-humidifier] This plugin generated a warning from the characteristic 'Water Level': characteristic value expected valid finite number and received "NaN" (number). See https://git.io/JtMGR for more info.
[11/27/2021, 9:26:47 PM] [homebridge-mi-humidifier] Error: 
    at WaterLevel.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2074:105)
    at WaterLevel.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1967:16)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1569:24
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:9:18
    at BaseHumidifier.getProp (/homebridge/node_modules/homebridge-mi-humidifier/src/devices/humidifier.ts:237:5)
    at WaterLevel.<anonymous> (/homebridge/node_modules/homebridge-mi-humidifier/src/devices/humidifier.ts:191:14)
    at WaterLevel.emit (events.js:400:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1544:14
    at new Promise (<anonymous>)
    at WaterLevel.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1542:12)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at WaterLevel.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:656:38)

This is my config:

        {
            "devices": [
                {
                    "disabled": false,
                    "name": "Humidifier",
                    "address": "192.168.2.33",
                    "token": "<TOKEN>",
                    "model": "deerma.humidifier.mjjsq",
                    "updateInterval": 10,
                    "autoSwitchToHumidityMode": false,
                    "disableTargetHumidity": true,
                    "temperatureSensor": {
                        "enabled": false,
                        "name": "Temperature"
                    },
                    "humiditySensor": {
                        "enabled": false,
                        "name": "Humidity"
                    },
                    "ledBulb": {
                        "enabled": false,
                        "name": "Led"
                    },
                    "buzzerSwitch": {
                        "enabled": false,
                        "name": "Buzzer"
                    },
                    "cleanModeSwitch": {
                        "enabled": false,
                        "name": "Clean Mode"
                    }
                }
            ],
            "platform": "MiHumidifier"
        }

Thank you in advance!

nt0xa commented 2 years ago

Hey @raulchen,

Could you please collect debug logs? You can do it by running homebridge like this:

DEBUG=miio-api* homebridge -D
raulchen commented 2 years ago

@russtone Thanks for your reply. Here are the debug logs of miio-api.

[11/28/2021, 1:59:38 AM] [MiHumidifier] [192.168.2.33] Fail to get device properties. SocketError: Timeout
2021-11-28T07:59:43.148Z miio-api:192.168.2.33:le3lbzou -> { id: 3884562689, method: 'get_prop', params: [ 'OnOff_State' ] }
2021-11-28T07:59:43.149Z miio-api:192.168.2.33:le3lbzou -> Packet {
  deviceId: 455782265,
  timestamp: 98026,
  checksum: <Buffer 44 81 78 93 54 26 f5 a9 bd d9 2b 8b c8 d4 cd 85>,
  data: <Buffer 3c 6b bd 06 31 f9 72 31 07 0c ad 1a 9d 56 da 41 28 85 31 08 8a a1 12 1c d6 85 08 fd bf 1e a6 ef 12 52 f3 e5 44 21 56 3b ce c2 1d 4f 26 cf 4e 24 0c 06 ... 14 more bytes>,
  unknown: 0
}
2021-11-28T07:59:43.149Z miio-api:192.168.2.33:le3lbzou #1 ->
0000    21 31 00 60 00 00 00 00 1b 2a af 79 00 01 7e ea 
0010    44 81 78 93 54 26 f5 a9 bd d9 2b 8b c8 d4 cd 85 
0020    3c 6b bd 06 31 f9 72 31 07 0c ad 1a 9d 56 da 41 
0030    28 85 31 08 8a a1 12 1c d6 85 08 fd bf 1e a6 ef 
0040    12 52 f3 e5 44 21 56 3b ce c2 1d 4f 26 cf 4e 24 
0050    0c 06 d3 4e 51 8b 88 ab 5f ba 6f ec e8 0a e7 4e 
2021-11-28T07:59:49.152Z miio-api:192.168.2.33:le3lbzou #2 ->
0000    21 31 00 60 00 00 00 00 1b 2a af 79 00 01 7e ea 
0010    44 81 78 93 54 26 f5 a9 bd d9 2b 8b c8 d4 cd 85 
0020    3c 6b bd 06 31 f9 72 31 07 0c ad 1a 9d 56 da 41 
0030    28 85 31 08 8a a1 12 1c d6 85 08 fd bf 1e a6 ef 
0040    12 52 f3 e5 44 21 56 3b ce c2 1d 4f 26 cf 4e 24 
0050    0c 06 d3 4e 51 8b 88 ab 5f ba 6f ec e8 0a e7 4e 
2021-11-28T07:59:55.155Z miio-api:192.168.2.33:le3lbzou #3 ->
0000    21 31 00 60 00 00 00 00 1b 2a af 79 00 01 7e ea 
0010    44 81 78 93 54 26 f5 a9 bd d9 2b 8b c8 d4 cd 85 
0020    3c 6b bd 06 31 f9 72 31 07 0c ad 1a 9d 56 da 41 
0030    28 85 31 08 8a a1 12 1c d6 85 08 fd bf 1e a6 ef 
0040    12 52 f3 e5 44 21 56 3b ce c2 1d 4f 26 cf 4e 24 
0050    0c 06 d3 4e 51 8b 88 ab 5f ba 6f ec e8 0a e7 4e
nt0xa commented 2 years ago

The logs shows that device is not responding which usually related to network problems. Could you check device using miiocli utility?

pip3 install python-miio
miiocli device --ip <ip> --token <token> info
raulchen commented 2 years ago

miiocli looks fine

Model: deerma.humidifier.jsqs
Hardware version: esp8266
Firmware version: 2.1.3
raulchen commented 2 years ago

also tried this:

$ miiocli -d airhumidifierjsq --ip 192.168.2.33 --token <token> status
INFO:miio.cli:Debug mode active
DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x1b*\xafy\x00\x01\x85\xa2' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('1b2aaf79')
            ts = 1970-01-02 03:42:26
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 1b2aaf79 with ts: 1970-01-02 03:42:26, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.2.33:54321 >>: {'id': 1, 'method': 'get_props', 'params': []}
DEBUG:miio.miioprotocol:192.168.2.33:54321 (ts: 1970-01-02 03:42:31, id: 1) << {'id': 1, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4020}
DEBUG:miio.click_common:Exception: {'code': -9999, 'message': 'user ack timeout'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/miio/click_common.py", line 280, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/miio/click_common.py", line 245, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/miio/click_common.py", line 193, in call
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/miio/airhumidifier_jsq.py", line 166, in status
    values = self.send("get_props")
  File "/usr/local/lib/python3.6/site-packages/miio/device.py", line 98, in send
    command, parameters, retry_count, extra_parameters=extra_parameters
  File "/usr/local/lib/python3.6/site-packages/miio/miioprotocol.py", line 214, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.6/site-packages/miio/miioprotocol.py", line 274, in _handle_error
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -9999, 'message': 'user ack timeout'}
Error: {'code': -9999, 'message': 'user ack timeout'}
nt0xa commented 2 years ago

Could you try to set model to deerma.humidifier.jsq4 instead of deerma.humidifier.mjjsq?

raulchen commented 2 years ago

deerma.humidifier.jsq4 works fine. Thanks!

nt0xa commented 2 years ago

Your model deerma.humidifier.jsqs is slightly different from deerma.humidifier.jsq4. For the most part everything should work fine, but there is one extra speed level. I've added support for deerma.humidifier.jsqs in the latest release 2.4.3.