Homekit users - which nodes have you installed?

I'm using the Homekit bridged node , however there is a known bug which means that node red needs restarting after every deploy (otherwise the Homekit nodes do not work).

The developer is working on a fix, which I am grateful for their hard work. But in the meantime, I'm interested what nodes other Homekit users are using.

As to be honest it is quite a nuisance to restart node red after each minor change/deployment.

Thanks :slight_smile:

I started with the homekit node, but have switched to homebridge-mqtt, this made everything so much faster and I haven't had any issues with homekit and can create any type of homekit device I want.

Deploy and the device is instantly added/removed, updated etc.
(yes it will require mqtt and homebridge but it is worth it).

1 Like

@bakman2 thanks for the speedy reply, I will give that a look.

I’m currently running Node Red and Mosquitto MQQT on a Raspberry Pi3, I take it it’s no problem to also install home bridge on that setup?

Did you just follow the homebridge Raspberry Pi setup guide?

Thanks :+1:

I have it running in a docker container on the pi. If you have docker/compose installed you can start at step 3.

1 Like

Cheers, I will have a look. Not used Docker before so I will give it a google :+1:

1 Like

@bakman2 I now have Homebridge running under docker, might I trouble you for some info?

I have the Homebridge hub showing up on my phone Home app, but having trouble with the MQQT setup.

I'm pretty sure it's the config.json, here it is:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },
    "platforms": [
        {
            "platform": "mqtt",
            "name": "mqtt",
            "url": "http://192.168.1.95",
            "port": "1883",
            "topic_type": "multiple",
            "topic_prefix": "homebridge",
            "username": "",
            "password": "",
            "qos": 1
        }
    ],
    "accessories": []
}

I don't have a username or password for Mosquitto MQQT server, in node red the fields are blank. I've tried lots of variations but it just won't connect, I get the "server restart is taking a long time" error.

Apologies as this is not technically a node red issue :blush:

Where do you get this error ? In homebridge/docker ?

Removing the username & password keys helps ?

1 Like

If you don't need the username and the password, you have to remove these parameters:

{
	"bridge": {
		"name": "Homebridge",
		"username": "CC:22:3D:E3:CE:30",
		"port": 51826,
		"pin": "031-45-154"
	},
	"platforms": [{
		"platform": "mqtt",
		"name": "mqtt",
		"url": "http://192.168.1.95",
		"port": "1883",
		"topic_type": "multiple",
		"topic_prefix": "homebridge",
		"qos": 1
	}],
	"accessories": []
}
1 Like

@bakman2 In the Homebridge UI http://192.168.1.95:8080

Hi @cflurin I tried removing those fields and get the same error.

I don't use the UI, don't know what the output is.

Could you try from the commandline ?
docker restart homebridge (or whatever it is called - docker ps will show the container name)
followed by
docker logs -f homebridge

Yes no problem, mine is called homebridge_homebridge_1 for some reason.

Here is the output:

[5/13/2019, 8:17:47 PM] Homebridge is running on port 51826.
[5/13/2019, 9:05:32 PM] [Config] Changes to config.json saved.
[5/13/2019, 9:05:39 PM] [Config] Homebridge restart request received
[5/13/2019, 9:05:39 PM] [Config] Executing restart command: killall -9 homebridge && killall -9 homebridge-config-ui-x
Killed
Killed
-U /homebridge -P /homebridge/node_modules -C
[5/13/2019, 9:05:44 PM] Loaded config.json with 0 accessories and 1 platforms.
[5/13/2019, 9:05:44 PM] ---
[5/13/2019, 9:05:44 PM] Loaded plugin: homebridge-dummy
[5/13/2019, 9:05:44 PM] Registering accessory 'homebridge-dummy.DummySwitch'
[5/13/2019, 9:05:44 PM] ---
[5/13/2019, 9:05:44 PM] Loaded plugin: homebridge-config-ui-x
[5/13/2019, 9:05:44 PM] Registering platform 'homebridge-config-ui-x.config'
[5/13/2019, 9:05:44 PM] ---
[5/13/2019, 9:05:44 PM] Loading 1 platforms...
[5/13/2019, 9:05:44 PM] Error: The requested platform 'mqtt' was not registered by any plugin.
    at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:134:13)
    at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:327:45)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:90:36)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
[5/13/2019, 9:05:44 PM] Got SIGTERM, shutting down Homebridge...
[5/13/2019, 9:05:46 PM] [Config] Console v4.4.0 is listening on :: port 8080
-U /homebridge -P /homebridge/node_modules -C
[5/13/2019, 9:05:53 PM] Loaded config.json with 0 accessories and 1 platforms.
[5/13/2019, 9:05:53 PM] ---
[5/13/2019, 9:05:53 PM] Loaded plugin: homebridge-dummy
[5/13/2019, 9:05:53 PM] Registering accessory 'homebridge-dummy.DummySwitch'
[5/13/2019, 9:05:53 PM] ---
[5/13/2019, 9:05:53 PM] Loaded plugin: homebridge-config-ui-x
[5/13/2019, 9:05:53 PM] Registering platform 'homebridge-config-ui-x.config'
[5/13/2019, 9:05:53 PM] ---
[5/13/2019, 9:05:53 PM] Loading 1 platforms...
[5/13/2019, 9:05:53 PM] Error: The requested platform 'mqtt' was not registered by any plugin.
    at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:134:13)
    at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:327:45)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:90:36)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

and it repeats the same over and over.

Quite clear :wink:

With docker you can link the config file to your local filesystem (else it will reside inside the container which will be overwritten when you update the container).
Did you install homebridge using the docker-compose method ?

Ah after reading through the log I think I see my mistake.

I installed the plugin via command line "sudo npm install -g homebridge-mqtt", but I think I installed it to the wrong folder.

I now just went into the Homebridge UI and installed the plugin, and after reboot it started first time!

Why don't you like using the UI? Probably I like it as it seems nice and safe and squishy :laughing:

Tomorrows task, learn more about creating flows with this new tool!

Thanks for your help!!! :+1:

Ps also many thanks to @cflurin for the plugin :+1:

UI is very nice, I am just more comfortable on the commandline as I can see stuff happening :wink:

I like homebridge-mqtt a lot, don't hesitate if you got questions.

1 Like

Yes that's true, I would have fixed the error if I knew how to read the log :blush:

Thanks for all the help, I really appreciate it! :+1:

I have to get some sleep now but I will have a good look tomorrow and start setting things up, I'll let you know how I get on. :smile:

1 Like

OK so I have had an hour looking at it and I am impressed with the responsiveness! :+1:

I've created a couple of simple flows to add/remove a switch and to control the switch state from node red.

I have to admit I am struggling with the whole concept of how to build flows. I 'think'' the whole thing runs on mqtt nodes, and each device is individually controlled by sending different payloads?

My existing mqtt setup uses this format:

house/lounge/sensor
house/kitchen/light
garage/light
and so on......

This does not seem possible with this setup, as everything uses the same topic, but with a different payload.

So for now I am unsure how to create a simple flow such as the below example of a dashboard switch and a Homekit switch controlling a Sonoff via mqtt.

I will continue to read as I'm sure I am misunderstanding something, any hints and tips would be much appreciated! :smile:

With the MQTT-out node, you can set msg.topic in the incoming msg and leave the topic blank in the MQTT node. That way, multiple mqtt messages with different topics can use the same node.

in your example, it you had a change node after each inject node that built msg.topic with the correct topic, they could all use one mqtt-out node.

For mqtt-in nodes, you can use # as a widl card you could have homebridge/from/# which would get both topic homebridge/from/response and homebridge/from/get, just use a switch node to directthe message to the leg of the flow you want.

Example flow I use with homekit

[{"id":"534c1b6.4260ee4","type":"mqtt out","z":"fb27fd4d.7e296","name":"","topic":"","qos":"0","retain":"false","broker":"228872c0.fd94d6","x":579,"y":138,"wires":[]},{"id":"4c9b626f.ae5614","type":"mqtt in","z":"fb27fd4d.7e296","name":"","topic":"homebridge/from/set/Fan","qos":"2","datatype":"json","broker":"228872c0.fd94d6","x":156,"y":92,"wires":[["7b840a95.24a784"]]},{"id":"df38a4fd.368268","type":"mqtt in","z":"fb27fd4d.7e296","name":"","topic":"homebridge/from/set/Boiler","qos":"2","datatype":"json","broker":"228872c0.fd94d6","x":166,"y":138,"wires":[["7b840a95.24a784"]]},{"id":"db5998c2.7eaf78","type":"mqtt in","z":"fb27fd4d.7e296","name":"","topic":"homebridge/from/set/Kleine Lamp","qos":"2","datatype":"json","broker":"228872c0.fd94d6","x":186,"y":184,"wires":[["7b840a95.24a784"]]},{"id":"7b840a95.24a784","type":"function","z":"fb27fd4d.7e296","name":"","func":"destination_topic = []\nm = msg.payload.value\nsource_topic = msg.topic\n\ndestination_topic[\"homebridge/from/set/Fan\"] = \"livingroom/fan/cmnd/POWER\" \ndestination_topic[\"homebridge/from/set/Boiler\"] = \"Boiler/relay/0/set\" \ndestination_topic[\"homebridge/from/set/Kleine Lamp\"] = \"livingroom/switch/cmnd/POWER\" \n\nif(m){\n    return {topic:destination_topic[source_topic],payload:1}\n}\nelse{\n    return {topic:destination_topic[source_topic],payload:0}\n}\n","outputs":1,"noerr":0,"x":441,"y":138,"wires":[["534c1b6.4260ee4","41619320.1d614c"]]},{"id":"41619320.1d614c","type":"debug","z":"fb27fd4d.7e296","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":578,"y":198,"wires":[]},{"id":"228872c0.fd94d6","type":"mqtt-broker","z":"","name":"mqtt","broker":"10.0.0.202","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]
1 Like

It doesn't work this way. Please read the doc.
You should also be familiar with the HomeKit protocol (HAP)

Example to turn on a lamp:

topic: homebridge/to/set

payload: 
{
 	"name": "flex_lamp",
 	"service_name": "light",
 	"characteristic": "On",
 	"value": true
 }

The name and the service_name can you define for your device.
the characteristic On and the value true or fasle have to be conform with the HAP.

Have a look here for all services and characteristcs:

https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js

and here for an introduction:

https://github.com/cflurin/homebridge-mqtt/wiki/homebridge2NodeRED

1 Like

It works that way towards my devices, not to homekit. Perhaps it is a bad example I would agree :')

1 Like