nt0xa / homebridge-mi-humidifier

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

deerma.humidifier.jsq: Fail to connect to device #53

Open pfrankov opened 3 years ago

pfrankov commented 3 years ago

While I'm running > DEBUG=miio-api* homebridge -D

I getting this error:

Fail to connect to device <IP>. TypeError: this.socket.connect is not a function

Model: deerma.humidifier.jsq

My config file:

{
            "devices": [
                {
                    "name": "Humidifier",
                    "address": "<IP>",
                    "token": "<TOKEN>",
                    "model": "deerma.humidifier.mjjsq",
                    "updateInterval": 30,
                    "temperatureSensor": {
                        "enabled": false,
                        "name": "Temperature"
                    },
                    "humiditySensor": {
                        "enabled": false,
                        "name": "Humidity"
                    },
                    "ledBulb": {
                        "enabled": false,
                        "name": "Led"
                    },
                    "buzzerSwitch": {
                        "enabled": false,
                        "name": "Buzzer"
                    }
                }
            ],
            "platform": "MiHumidifier"
        }

> miio tokens update...

 INFO  Connected to miio:248157080  - trying to change token

Token has been updated

> DEBUG=miio\*,thing\* miio inspect <IP>

...
Device ID: 248157080
Model info: deerma.humidifier.jsq
Address: <IP>
Token: <TOKEN> via stored token
Support: At least generic

Type info: miio
Capabilities:

Firmware version: 2.0.7
Hardware version: esp8266
MCU firmware version: 0113

Do you have any ideas why this could happen?


This is interesting, I have almost the same issue with other plugin:

 [Xiaomi Mi Robot Vaccum 1st Generation] ERR connect | miio.device, next try in 2 minutes | Error: Could not connect to device, handshake timeout

But because it has retries it suddenly starts working: https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/blob/master/index.js#L752 Or maybe it's just a coincidence.

nt0xa commented 3 years ago

Hey @pfrankov, I'm using own implementation of miio protocol and I haven't tested it on older versions of NodeJS. It seems that feature I used "connected UDP sockets" which was introduced only in NodeJS v12 (https://nodejs.org/docs/latest-v12.x/api/dgram.html#dgram_socket_connect_port_address_callback) and you are using v10. NodeJS 10 is LTS, so I will try to add its support to my miio implementation.

nt0xa commented 3 years ago

I've update miio-api (russtone/miio-api#2), so issue should be fixed now. But you might need to reinstall the plugin in order to get the latest versions of the dependencies

pfrankov commented 3 years ago

Thank you! But it seems that if I have homebridge-mi-humidifier installed the whole Homekit is not working after couple of minutes. All devices are not responding anymore. To make everything work properly I've tried to turn off the homebridge-mi-humidifier part in the config file. And it was not enough. Only after complete removing AND rebooting both Homebridge and iPhone it started working as before.

nt0xa commented 3 years ago

This is strange when I tested the plugin on NodeJS v10 everything worked fine. Could you please collect some debug logs?

Ugmaxie commented 3 years ago

Mine doesn't work too :(

Homebridge UI v1.2.5 as 1.3.x have issues with Aqara plugin (AC cannot be managed)

Device ID: 248550658
Model info: deerma.humidifier.jsq
Address: 192.168.4.1
Token: ********************************* via auto-token
Support: At least generic
Screenshot 2021-03-14 at 21 37 23
Ugmaxie commented 3 years ago

@russtone some more info:

[3/17/2021, 7:12:52 AM] [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.
[3/17/2021, 7:12:52 AM] [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.
[3/17/2021, 7:12:52 AM] [homebridge-mi-humidifier] This plugin generated a warning from the characteristic 'Relative Humidity Humidifier Threshold': characteristic value expected valid finite number and received "undefined" (undefined). See https://git.io/JtMGR for more info.

[3/17/2021, 7:12:54 AM] [MiHumidifier] [10.0.1.84] Fail to get device properties. SocketError: Timeout
[3/17/2021, 7:13:24 AM] [MiHumidifier] [10.0.1.84] Fail to get device properties. SocketError: Timeout
[3/17/2021, 7:13:54 AM] [MiHumidifier] [10.0.1.84] Fail to get device properties. SocketError: Timeout
[3/17/2021, 7:14:24 AM] [MiHumidifier] [10.0.1.84] Fail to get device properties. SocketError: Timeout
[3/17/2021, 7:14:54 AM] [MiHumidifier] [10.0.1.84] Fail to get device properties. SocketError: Timeout

Homebridge : v1.3.4 Node.js : v14.15.0 NPM : v6.14.8 homebridge-mi-humidifier : v2.3.1

UPDATE: Mine is fixed I was obtaining an incorrect token by miio, so after getting token via iOS backup and decoding it - all started to work!

nt0xa commented 3 years ago

Hey @Ugmaxie

Error SocketError: Timeout usually related to network connection problems. Are you sure that device IP is correct? I see that device IP in miio output is 192.168.4.1 and it is not the same as in logs 10.0.1.84.

Warnings are not related to error I will try to fix them in the next release