# Homekit users - which nodes have you installed?

**URL:** https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044
**Category:** General
**Created:** [12 May 2019 16:26 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044 "2019-05-12T16:26:41Z")
**Posts on this page:** 10
**Page:** 2

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [15 May 2019 08:07 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/21 "2019-05-15T08:07:49Z")

</div>

Ops I see, you are right. Probably you did set "topic\_type": "single" ?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [15 May 2019 10:47 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/22 "2019-05-15T10:47:32Z")

</div>

That is correct. I wasn't sure about the advantage of `multiple`.  
I find the accessory + services a bit confusing.

If I understand correctly: you can have an accessory with optional associated services (like BatteryLevel, SulphurDioxideDensity, LeakDetected etc) ?

---

<div class="post-metadata">

### Author: ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)
#### Post date: [15 May 2019 12:53 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/23 "2019-05-15T12:53:36Z")

</div>

> [@bakman2](#):
>
> Example flow I use with homekit

Thank you @bakman2 for the example, I have been looking at it for a little while. Apologies for all the questions, I have very little javascript knowledge which is letting me down 😊

Am I correct that to control more (or all) accessories, the relevant topics could just be added to the one function?

i.e.

```auto
destination_topic = []
m = msg.payload.value
source_topic = msg.topic

destination_topic["homebridge/from/set/Fan"] = "livingroom/fan/cmnd/POWER" 
destination_topic["homebridge/from/set/Boiler"] = "Boiler/relay/0/set" 
destination_topic["homebridge/from/set/Kleine Lamp"] = "livingroom/switch/cmnd/POWER" 
destination_topic["homebridge/from/set//Lights"] = "garage/lights/cmnd/POWER" 
destination_topic["homebridge/from/set/Heater"] = "garage/heater/cmnd/POWER" 

if(m){
    return {topic:destination_topic[source_topic],payload:1}
}
else{
    return {topic:destination_topic[source_topic],payload:0}
}

```

and that a seperate flow can be used to add/remove the devices i.e. "administration purposes"?

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [15 May 2019 13:17 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/24 "2019-05-15T13:17:02Z")

</div>

> [@bakman2](#):
>
> That is correct. I wasn't sure about the advantage of `multiple` .

The homebridge-mqtt basic concept is to exchange the row data using the HAP (Homekit) Protocol. The API is based on the HomeKit definitions (services, characteristics). This way the API is designed for future extensions.

I generally use the topic\_type `multiple` with one mqtt-in node which is wired to a switch-node to select the accessory-name.

> [@bakman2](#):
>
> If I understand correctly: you can have an accessory with optional associated services (like BatteryLevel, SulphurDioxideDensity, LeakDetected etc) ?

Yes, you can define an accessory with the default service and add additional services as needed.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [15 May 2019 13:29 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/25 "2019-05-15T13:29:11Z")

</div>

Yes indeed. Ofcourse you can use a switch node instead, like @cflurin indicated, my "solution" is a bit clunky.

For the setup I have one flow with the whole setup (in principle you only have to do this once, but who knows if your broker or homebridge messes up and you have to add it again).

This is my setup:

```auto
[{"id":"cfb1c2de.8fb798","type":"mqtt out","z":"ac3a9890.7ebed","name":"","topic":"","qos":"0","retain":"false","broker":"228872c0.fd94d6","x":430,"y":160,"wires":[]},{"id":"afccd162.8365b8","type":"function","z":"ac3a9890.7ebed","name":"","func":"m = msg.payload\nif(m){\nt = \"homebridge/to/add\"\n}else{\nt = \"homebridge/to/remove\"\n \n}\n node.send({topic:t,payload:{\"name\":\"netatmo_temperature\",\"service_name\":\"netatmo_temperature\",\"service\":\"TemperatureSensor\"}})\n node.send({topic:t,payload:{\"name\":\"netatmo_co2\",\"service_name\":\"netatmo_co2\",\"service\":\"CarbonDioxideSensor\"}})\n node.send({topic:t,payload:{\"name\":\"netatmo_humidity_indoor\",\"service_name\":\"netatmo_humidity_indoor\",\"service\":\"HumiditySensor\"}})\n node.send({topic:t,payload:{\"name\":\"deurbel\",\"service_name\":\"deurbel\",\"service\":\"Switch\"}})\n node.send({topic:t,payload:{\"name\":\"netatmo_humidity_outdoor\",\"service_name\":\"netatmo_humidity_outdoor\",\"service\":\"HumiditySensor\"}})\n node.send({topic:t,payload:{\"name\":\"netatmo_temperature_outdoor\",\"service_name\":\"netatmo_temperature_outdoor\",\"service\":\"TemperatureSensor\"}})\n node.send({topic:t,payload:{\"name\":\"zonnescherm\",\"service_name\":\"zonnescherm\",\"service\":\"WindowCovering\"}})\n node.send({topic:t,payload:{\"name\":\"Thermoswitch\",\"service_name\":\"Thermoswitch\",\"service\":\"Switch\"}})\n node.send({topic:t,payload:{\"name\":\"Kleine Lamp\",\"service_name\":\"Kleine Lamp\",\"service\":\"Switch\"}})\n node.send({topic:t,payload:{\"name\":\"Boiler\",\"service_name\":\"Boiler\",\"service\":\"Switch\"}})\n node.send({topic:t,payload:{\"name\":\"Fan\",\"service_name\":\"Fan\",\"service\":\"Switch\"}})\n //node.send({topic:t,payload:{\"name\":\"lux\",\"service_name\":\"lux\",\"service\":\"LightSensor\"}})\n node.send({topic:t,payload:{\"name\":\"motion\",\"service_name\":\"motion\",\"service\":\"MotionSensor\"}})\n \n \n ","outputs":1,"noerr":0,"x":250,"y":140,"wires":[["9600a6d8.7e288","cfb1c2de.8fb798"]]},{"id":"d703e9e3.ca287","type":"inject","z":"ac3a9890.7ebed","name":"add","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":120,"wires":[["afccd162.8365b8"]]},{"id":"9600a6d8.7e288","type":"debug","z":"ac3a9890.7ebed","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":120,"wires":[]},{"id":"b7e22628.59e89","type":"inject","z":"ac3a9890.7ebed","name":"remove","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":160,"wires":[["afccd162.8365b8"]]},{"id":"a3623721.798708","type":"comment","z":"ac3a9890.7ebed","name":"Homebridge MQTT setup","info":"","x":150,"y":80,"wires":[]},{"id":"c8e15806.024bb","type":"function","z":"ac3a9890.7ebed","name":"","func":"m = msg.payload\nif(m){\n set = \"add\"\n}\nelse{\n set = \"remove\"\n}\nt = \"homebridge/to/\"+set\n \n\n node.send({topic:t,payload:{\"name\":\"TV\",\"service_name\":\"TV\",\"service\":\"Television\",characteristic:\"InputSourceType\", value:3}})\n\n \n ","outputs":1,"noerr":0,"x":248,"y":308,"wires":[["cfb1c2de.8fb798"]]},{"id":"2fff8f91.6830b8","type":"inject","z":"ac3a9890.7ebed","name":"add","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":300,"wires":[["c8e15806.024bb"]]},{"id":"6580f0e9.6deb6","type":"mqtt in","z":"ac3a9890.7ebed","name":"","topic":"homebridge/from/#","qos":"0","datatype":"json","broker":"228872c0.fd94d6","x":130,"y":440,"wires":[["8cad8621.3bb788"]]},{"id":"8cad8621.3bb788","type":"debug","z":"ac3a9890.7ebed","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":310,"y":440,"wires":[]},{"id":"32b918fc.94e93","type":"inject","z":"ac3a9890.7ebed","name":"remove","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":340,"wires":[["c8e15806.024bb"]]},{"id":"62aa1f2a.a0d4c8","type":"comment","z":"ac3a9890.7ebed","name":"Single service","info":"","x":110,"y":240,"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":""}]

```

---

<div class="post-metadata">

### Author: ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)
#### Post date: [15 May 2019 16:13 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/26 "2019-05-15T16:13:09Z")

</div>

> [@cflurin](#):
>
> I generally use the topic\_type `multiple` with one mqtt-in node which is wired to a switch-node to select the accessory-name.

Hi @cflurin could you give an example flow for a newbie? I'm not sure how a switch node can be used to select the accessory name 😄

@bakman2 thank you for your help and flow, I will endeavour to understand how it works! 😉

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [15 May 2019 16:17 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/27 "2019-05-15T16:17:04Z")

</div>

with a switch you can filter based on msg.topic and route to your devices.

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [15 May 2019 16:57 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/28 "2019-05-15T16:57:30Z")

</div>

> [@877](#):
>
> Hi @cflurin could you give an example flow for a newbie? I'm not sure how a switch node can be used to select the accessory name 😄

![homebridge_example2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0dd61aab84a5ff83f91c867cee6e8d8892efd658.png)

```auto
[{"id":"b6161624.207848","type":"switch","z":"7c6a9ec3.f1512","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"at_home","vt":"str"},{"t":"eq","v":"heating_control","vt":"str"},{"t":"eq","v":"heating","vt":"str"},{"t":"eq","v":"alarm","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":390,"y":1200,"wires":[["7a300db5.5842b4"],["cbd291b4.da196"],["f8bdaa92.c61ef8"],["92421ecc.339f7"],["5ca715ca.c98fec"]]},{"id":"e32c32a0.f8a75","type":"mqtt in","z":"7c6a9ec3.f1512","name":"","topic":"homebridge/from/set","qos":"2","datatype":"json","broker":"ff0b6f99.b41c1","x":180,"y":1200,"wires":[["b6161624.207848"]]},{"id":"7a300db5.5842b4","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":1120,"wires":[]},{"id":"cbd291b4.da196","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":1160,"wires":[]},{"id":"f8bdaa92.c61ef8","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":1200,"wires":[]},{"id":"92421ecc.339f7","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":1240,"wires":[]},{"id":"5ca715ca.c98fec","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":1280,"wires":[]},{"id":"ff0b6f99.b41c1","type":"mqtt-broker","z":"","name":"","broker":"my_brocker","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

Replace `my_broker` with the ip-address/name of your mqtt broker.

---

<div class="post-metadata">

### Author: ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)
#### Post date: [16 May 2019 20:12 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/29 "2019-05-16T20:12:23Z")

</div>

Thank you! 😄

---

<div class="post-metadata">

### Author: ![mriksman](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@mriksman](https://discourse.nodered.org/u/mriksman)
#### Post date: [11 January 2020 05:43 UTC](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044/30 "2020-01-11T05:43:42Z")

</div>

For anyone else browsing the Internet;

> [@Thoughts on a general Zigbee to Homebridge (HomeKit) converter](https://discourse.nodered.org/t/thoughts-on-a-general-zigbee-to-homebridge-homekit-converter/18742/14):
>
> This is working pretty well so far as an automated handler for homebridge-mqtt. Handles Tasmota devices with multiple switches (POWER, POWER2, POWER3), and Outlets with Power Consumption (uses Current to determine OutletInUse). Handles odd edge cases where a device has two services and requires the use of /add/service; works well, a two switch device is joined together in the Home app. [flows.txt](https://discourse.nodered.org/uploads/short-url/eZRyl1EMhmuJWaXBjrH26rqKI2e.txt) (13.1 KB)

[Previous page](https://discourse.nodered.org/t/homekit-users-which-nodes-have-you-installed/11044.md?page=1)
