Open drozel opened 5 years ago
Indeed: thank you for the package: exactly what I needed to integrate Xiaomi devices with a home automation system via NodeRed !
I think I have a similar issue as was mentioned by @drozel On a completely new install (new raspberry PI, new Node-red) I try to connect to a Xiaomi gateway. All settings are entered correctly but no connection is made. Also getting "key is not set" and if I look at my raspberry console, it tells me : "UDP socket listening on 0.0.0.0:8989", where I think the IP address should be filled in?
Willems-m, during waiting for the answer i've looked into the code and found out this message.
if (this.key && this.currentToken) { .... } else { this.error('key is not set'); }
it means, the error text is just not accurate and, in case the key is entered, it should be the second condition. As far as i understood it, this token is being generated at the beginning of communication with the gateway (which should happen after deployment automatically) So, i suspect, package just can't connect with the xiaomi. The text "not connected" under the block is also proof of this fact.
But i still can't understand, why it can't connect to, because my gateway perfectly worked with the hassio
I think I have a similar issue as was mentioned by @drozel On a completely new install (new raspberry PI, new Node-red) I try to connect to a Xiaomi gateway. All settings are entered correctly but no connection is made. Also getting "key is not set" and if I look at my raspberry console, it tells me : "UDP socket listening on 0.0.0.0:8989", where I think the IP address should be filled in?
No IP address should not be there, case gateway node is listening to broadcast port and not IP address of the gateway.
I noticed that you set the wrong port, the port is 9898 and not 8989. You can leave this field empty and default value will be set
@igdr thanks! it began to work after i removed both - IP and port!
I got the list of sensors from HUB.
Just as improvement suggestion: it's not really intuitive that IP must remain empty.. I've tried everything but didn't come to idea to remove IP =)
You can set the IP, this field actually is not used now. This field is a part of the feature of the support for multiple gateways which is not implemented yet.
Argh.. The problem was the wrong port! Sorry and thank you for helping!
By the way, everything in my system works now, it's perfect!
Thanks for the clarification! Unfortunately I still get "not Connected" and "Key is not set" is debugging. Even after removing the port and IP address.
Thanks for the clarification! Unfortunately I still get "not Connected" and "Key is not set" is debugging. Even after removing the port and IP address.
Can you show the output from the terminal console when you started NodeRed?
Hello,
This is a copy-paste of the console window. If you do need any more details, happy to help !
30 Jun 13:32:24 - [info]
30 Jun 13:32:24 - [info] Node-RED version: v0.20.6 30 Jun 13:32:24 - [info] Node.js version: v10.16.0 30 Jun 13:32:24 - [info] Linux 4.19.50-v7+ arm LE 30 Jun 13:32:25 - [info] Loading palette nodes 30 Jun 13:32:31 - [info] Dashboard version 2.15.5 started at /ui 30 Jun 13:32:32 - [info] Settings file : /home/pi/.node-red/settings.js 30 Jun 13:32:32 - [info] Context store : 'default' [module=memory] 30 Jun 13:32:32 - [info] User directory : /home/pi/.node-red 30 Jun 13:32:32 - [warn] Projects disabled : editorTheme.projects.enabled=false 30 Jun 13:32:32 - [info] Flows file : /home/pi/.node-red/start 30 Jun 13:32:32 - [info] Server now running at http://127.0.0.1:1880/ 30 Jun 13:32:32 - [warn]
30 Jun 13:32:32 - [info] Starting flows UDP socket is aleady used, try to reuse 9898 30 Jun 13:32:33 - [info] Started flows 30 Jun 13:32:33 - [info] [xiaomi-gateway-config:My Gateway] UDP socket listening on 0.0.0.0:9898 30 Jun 13:32:33 - [info] [xiaomi-gateway-config:Xiaomi] UDP socket listening on 0.0.0.0:9898
@Willems-m You could also check if your xiaomi support the API access. I heard there is not accessible models (fw versions).
The check is
netcat -ukl 9898
on your machine. But you have deactivate nodered first since the port is already busy by them.
@drozel apologies for the late reply, was away for business.
I ran netcat -ukl 9898
but that didn't give me any result, it literally kept running with no result.
There seems to be a problem with my gateway that has now closed port 9898, when I run NMAP against the IP address I do get the remark that this port is closed.
PORT STATE SERVICE
9898/udp closed monkeycom
MAC Address: 04:CF*******
I read on another forum that this is a common problem and there doesn't seem to be an easy fix unfortunately. If you have any experience with this, please let me know!
@Willems-m sorry, i have also no idea about that... I've seen video tutorials where a man disassembled the hub and flashed it via COM port to make API work.. I guess, it is your case. As i said, my hub worked perfectly before and i knew, it's not so deep problem in my case
@drozel Thanks for all the help! I've seen the video's too, maybe I'll attempt that. Or I'll just try with a new Gateway. As this might help future readers: the problem seems to be when you don't enable Developer mode before doing a firmware upgrade. This upgrade to any more recent version, would then close the port.
Hi I have just bought xiaomi gateway V3 with xiaomi temperature sensors. I also have same problem. Nodered can not connect with Xiaomi gateway. I have updated gateway firmware to latest version before I activate the developer mode. If you guys have any more suggestion, please help me. Thanks
Hi I have just bought xiaomi gateway V3 with xiaomi temperature sensors. I also have same problem. Nodered can not connect with Xiaomi gateway. I have updated gateway firmware to latest version before I activate the developer mode. If you guys have any more suggestion, please help me. Thanks
I wasn't able to connect gateway v2 to HA , but this solution (Russion lang) helped me https://sprut.ai/client/article/1576
Hi, Got the same problem and busted the head for around 6 hours... First you need to disable the developer mode. Than delete the gateway from the app (developer mode set to off mandatory). Add the gateway to mi home and activate the developer mode. The first key is the one that is working, use that one.
This is what worked for me.
Hello,
Thanks for the node.
I actually have this same issue with this in the log :
[info] [xiaomi-gateway-config:Gateway] UDP socket listening on 0.0.0.0:9898
I run nodered on docker, can this be the problem ?
PS:
Thanks
Hi, I'm having trouble with this message " key is not set" I'm using gateway.V3 version and I have managed to switch it in developerMode(local) to get the Password(key). I managed to get the key by installing an older version of apk Mi Home 5.0.8 where the hidden menu could be accessed from About I downloaded from here: https://mi-home.en.uptodown.com/android/versions
After that I've seen that the port 9898 is opened with this command : sudo nmap -sU -v -p 9898 192.168.1.x and I got this response
PORT STATE SERVICE 9898/udp open monkeycom MAC Address: F0:B4:29:B4:35:13 (Xiaomi Communications)
so the UDP port is open! Should I have the 9898 TCP port also open? but still my module doesn't connect to the gateway I configured the node without the IP and Address as instructed here but nothing, still no connection to gateway with the message "key is not set"
should I forward port 9898 on the router? I also don't know how the module finds my device based on the key since no IP is configured. Could someone with more experience explain what is going on? Thank you
Hi, firstly thank you for the package=)
I'm trying to control my xiaomi hub. In order to obtain the devices list from the hub i using "Xiaomi Gateway Utils" box. Gateway is configured, key is entered (i've already controlled the hub via home-assistant before). After i trigger the box (i'm also not sure i give correct input data - there is no information in the help of this box) i receiving the error "key is not set" (see screenshots). Sorry if i'm missing important basic knowledge about node-red, it's my first try to use it.