cflurin / homebridge-mqtt

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

HELP how i can add accessory to config.js #17

Closed Maxmudjon closed 7 years ago

Maxmudjon commented 7 years ago

HELP how i can add accessory to config.js please example

cflurin commented 7 years ago

config.js is only used for defining the platform and the MQTT broker! Accessories can be added (and removed) at runtime. Take a look at README and Wiki

Maxmudjon commented 7 years ago

plase example file config.json please send me

cflurin commented 7 years ago

As in README explained:

{
    "bridge": {
        "name": "homebridge",
        "username": "CC:22:3D:E3:CE:31",
        "port": 51826,
        "pin": "031-45-154"
    },
    "platforms": [
        {
        "platform":"mqtt",
        "name":"mqtt",
        "url":"mqtt://your_broker_ip",
        "username":"your_name",
        "password":"your_password"
        }
    ],
    "accessories": []
}

Create a file config.json in your homebridge dir on a Raspberry e.g. home/pi/.homebridge and paste the def above.

Maxmudjon commented 7 years ago

HOW TO WRITE ?

topic: homebridge/to/add payload: {"name": "flex_lamp", "service": "Switch"}

cflurin commented 7 years ago

Hmmm! To use homebridge-mqtt you should have knowledge about MQTT, MQTT-broker. Google is your friend e.g.: http://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt

Maxmudjon commented 7 years ago

you have example accessory ?

Maxmudjon commented 7 years ago

you have a ready-made accessory, such as lamp control ?

cflurin commented 7 years ago

Sorry, I tried my best describing the API and the examples in the wiki. Maybe some other user can help you.

Maxmudjon commented 7 years ago

{ "bridge": { "name": "homebridge", "username": "CC:22:3D:E3:CE:31", "port": 51826, "pin": "031-45-154" }, "platforms": [ { "platform":"mqtt", "name":"mqtt", "url":"mqtt://your_broker_ip", "username":"your_name", "password":"your_password" } ], "accessories": [ topic: homebridge/to/add payload: {"name": "Lampa", "service": "Switch"} ] }

Maxmudjon commented 7 years ago

I write the code correctly

maragelis commented 7 years ago

No you need to send accessories through mqtt not the config file. Read about mqtt and json.