NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
418 stars 52 forks source link

NRCHKB-device could not be added in HomeKit-App #252

Closed frooonk closed 4 years ago

frooonk commented 4 years ago

I have already created a lot of flows with the "old" node-red-contrib-homekit nodes and have had no problems with it so far. Now I finally want to switch to the NRCHKB bridged version.

For testing, I created a new flow with a single NRCHKB node. The NRCHKB bridge is even displayed in the Homekit app and I can also enter the NRCHKB-node's Homekit PIN. However, I do not succeed in adding the bridge as a new device in the Homekit app, because the process is canceled after about 2-3 minutes with an error message: "Device could not be added".

The MDSN service in my network is activated and all firewall rules of my VLANs are deactivated (the homekit hub is in a different VLAN than NodeRed, but that has always worked with the "old" node-red-contrib-homekit nodes). The HomeKit-PIN I defined in the NRCHKB-node is not used otherwise.

Does somebody has any idea?

Shaquu commented 4 years ago

Could you share your node-red flow?

Also please start mode-red in debug mode(read our readme) and look for errors in logs.

frooonk commented 4 years ago

I just tested with the simple Quick Start Example: https://github.com/NRCHKB/node-red-contrib-homekit-bridged/wiki/Quick-Start

My new Node-Red installation runs in a docker container (gcgarner's IOTstack) and I'm still trying to figure out how I can start Node-Red using the debug command "DEBUG=NRCHKB,Accessory,HAPServer,EventedHTTPServer node-red" in the docker-console or in the Portainer-Web-UI.

jay-pee commented 4 years ago

have the same problem. Running node red in the docker container. Is there a problem with port forwarding maybe? I tried to set up port in node red:

image

and put a port forwarding in my docker compose file:

    nodered:
        container_name: nodered
        image: raymondmm/node-red-homekit
        restart: unless-stopped
        user: "0"
        privileged: true
        ports:
            - 1880:1880
            - 1881:1881
        volumes:
            - ./volumes/nodered/data:/data

but it doesn't work. Still can't find the "accessory" when trying to add it on iOS

Edit: On the github repo to the docker file (https://github.com/RaymondMouthaan/node-red-homekit-docker) is mentioned that you have to add network_mode: "host" to your config otherwise it will not work. however when I do that I can't access nodered on localhost:1880 anymore. Have to do more research why.

Edit2: I installed NRCHKB directly on the respbarry pi and it worked. So it must have something todo with the docker container...

Nailgun1980 commented 4 years ago

Hi all,

Iḿ running currently into the same issue then @frooonk

I have installed node-red on a debian system and updated node and npm to the most recent versions. After that I have installed the node-red-contrib-homekit-bridged. After setting up the mentioned quickstart example I could see the device in Homekit. But if I try to add that device it just runs into a timeout.

I`m not using docker or so. Just the standard installation.

Any advises?

Forgot to mention that node-red web interface is reachable by iphones browser. Both devices (node-red server and iphone are in the same network)

TheNON75 commented 4 years ago

@frooonk,@jay-pee what is the network config of your docker based nodered? I am using the official nodered docker image in host mode with no single problem. Bridge may cause issues with many docker solutions

frooonk commented 4 years ago

I installed NRCHKB directly on a new Raspi and it worked. So it can't have something todo with my HomeKit-Environment ...

@TheNON75,@jay-pee my nodered-container is connected to the network "iotstack_default". In the Network list of Portainer-Web-UI this network is displayed with "Scope : local", "Driver : bridge", "Subnet : 172.18.0.0/16", "Gateway : 172.18.0.1". There are also other containers running in the same network 172.18.0.x (pihole, influxdb, tasmoadmin, mosquitto, portainer, grafana).

Here is what I can see, if I click "inspect" in the Container details of my nodered-container in the Portainer-Web-UI. If I have hidden too much, please give me a short feedback.

{ ... "NetworkMode": "iotstack_default", ... "PortBindings": { "1880/tcp": [ { "HostIp": "", "HostPort": "1880" } ] }, ... "NetworkSettings": { "Bridge": "", "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "HairpinMode": false, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "MacAddress": "", "Networks": { "iotstack_default": { "Aliases": [ "nodered", "blablabla" ], "DriverOpts": null, "EndpointID": "...", "Gateway": "172.18.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAMConfig": null, "IPAddress": "172.18.0.7", "IPPrefixLen": 16, "IPv6Gateway": "", "Links": null, "MacAddress": "blablabla", "NetworkID": "blablabla" } }, "Ports": { "1880/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "1880" } ] }, ...

TheNON75 commented 4 years ago

Hi @frooonk,

Honestly, I am too lazy to configure everything so deeply, therefore I am using docker on a Synology with docker UI, so I am not that expert with such detailed configuration entries, however it is clear that you are using it in bridge mode, that you should change to host and give a try. With “host” is the setting such things as nodered is working well for me and in many cases this is the recommended setting.

The other thing is, that due to my personal idiotic brain, I am always installing (wherever It is possible) the original or originally recommended image and then loading such customizations and add ons. Also in this case I am running nodered/node-red and installed nrchkb on it via the “manage palette” in nodered. All these I can access via my synoipaddr:1880

So I would definitely give a try with the network config “host” at least

frooonk commented 4 years ago

@Nailgun1980 If I understand you correctly, then you have the same problem, even without node-red running in a docker container...

Maybe you can try Shaquu's advice: first stop node-red, then start node-red again in debug mode with the following command in the terminal of your debian system:

DEBUG=NRCHKB,Accessory,HAPServer,EventedHTTPServer node-red

and look for errors in logs.

Nailgun1980 commented 4 years ago

Thanks a lot @frooonk

that hint pointed me to the correct direction. My UFW did block EventedHTTPServers port. So I added the rules and connection could be established immediately.

frooonk commented 4 years ago

@Nailgun1980 I'm happy for you! Which ports did you have to open or forward?

I'm still looking for a solution for the problem with my nodered-setup running in GCGarner's IOTstack. So far nobody could tell me how to start the nodered-container with the debug parameters from shaquu ...

@jay-pee

On the github repo to the docker file (https://github.com/RaymondMouthaan/node-red-homekit-docker) is mentioned that you have to add network_mode: "host" to your config otherwise it will not work. however when I do that I can't access nodered on localhost:1880 anymore. Have to do more research

I added "network_mode: host" in my docker-compose.yml and service.yml files, but even after restarting the nodered container, nothing changes. In the Portainer Web-UI, the nodered container cannot be assigned to the "host" network either.

Nailgun1980 commented 4 years ago

@frooonk I had to add port 34535 and also for ipv6.

frooonk commented 4 years ago

I set network_mode: "host" in the docker-compose.yml , but I didn't know that I have to bring it up via docker-compose up -d !!!

Now it works and I can convert all my existing nodered-flows (there are many!) with the old homekit-nodes to NRCHKB.

Thank you all very much again :-)