cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 39 forks source link

I don't understand where topic/payload go in homebridge config.json #103

Closed JasonY00 closed 4 years ago

JasonY00 commented 4 years ago

Please excuse me for being so stupid! I just can't work out where the topic: / payload: options go in the homebridge config.json file.

I wish to read the state/data from my already defined homebridge accessories (created by other homebridge pugins) and send them to MQTT so that I can forward the state/data of the accessories to a Magic Mirror.

I have the following in my homebride config.json file:

"platforms": [ { "platform": "mqtt", "name": "mqtt", "url": "mqtt://192.168.1.12", "port": "1883", "topic_type": "multiple", "topic_prefix": "homebridge", "qos": 1 }, ...

Homebridge successfully connects to the MQTT server as below from the homebridge log

[6/28/2020, 6:56:13 PM] Loaded plugin: homebridge-mqtt@0.6.2 homebridge API version: 2.6 [6/28/2020, 6:56:13 PM] Registering platform 'homebridge-mqtt.mqtt' [6/28/2020, 6:56:13 PM] --- [6/28/2020, 6:56:14 PM] [mqtt] Initializing mqtt platform... [6/28/2020, 6:56:14 PM] [mqtt] homebridge-mqtt v0.6.2 [6/28/2020, 6:56:14 PM] [mqtt] storagePath = /var/lib/homebridge [6/28/2020, 6:56:14 PM] [mqtt] config = {"platform":"mqtt","name":"mqtt","url":"mqtt://192.168.1.12","port":"1883","topic_type":"multiple","topic_prefix":"homebridge","qos":1} [6/28/2020, 6:56:14 PM] [mqtt] Number of cached Accessories: 0 [6/28/2020, 6:56:14 PM] [mqtt] Controller.start [6/28/2020, 6:56:14 PM] [mqtt] clientId = homebridge-mqtt_69e6d80b [6/28/2020, 6:56:14 PM] [mqtt] Connecting.. [6/28/2020, 6:56:15 PM] [mqtt] connected (url = mqtt://192.168.1.12) [6/28/2020, 6:56:15 PM] [mqtt] on.connect subscribe homebridge/to/# [6/28/2020, 6:56:15 PM] [mqtt] on.connect homebridge-mqtt v0.6.2 started

But, for example, how would I read the data from a temperature sensor (already in homebridge) named "Man Cave Temp" and send that to my MQTT broker? I have tried to read data into Node Red with a flow but I'm not seeing anything coming in...

I have looked through the examples on the Wiki for homebridge-mqtt but nothing says where I define the topic/payload info.

If someone can give me an example topic/payload for the above temperature sensor and say where it goes e.g. in homebridge config.json that would be great! I don't see how the syntax works to define it under the platform section. I keep getting json syntax errors in the homebridge UI when I try to add it there.

Thank you in advance, I'm really sorry to ask such a stupid question, but I just can't work it out...or have I completely missed the point! Feel free to flame me mercilessly. I will put up with it just to get it going.

Cheers and thanks

Jason

cflurin commented 4 years ago

see: https://github.com/cflurin/homebridge-mqtt/issues/8

JasonY00 commented 4 years ago

Thanks for your reply. I still don't understand where to put the topic/payload, but with homebridge accessory status being what I needed, I used the homebridge-nod-red option from Northern-Man to achieve what I needed. Thanks for your reply.

Cheers

Jason