Homekit users - which nodes have you installed?

Ops I see, you are right. Probably you did set "topic_type": "single" ?

1 Like

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) ?

1 Like

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 :blush:

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

i.e.

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"?

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.

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

1 Like

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:

[{"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":""}]

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 :smile:

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

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

1 Like

homebridge_example2

[{"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.

1 Like

Thank you! :smile:

For anyone else browsing the Internet;