Giter VIP home page Giter VIP logo

homebridge's Introduction

Homebridge

Unlocking Door

Homebridge is a lightweight NodeJS server you can run on your home network that emulates the iOS HomeKit API. It supports Plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of "smart home" devices.

Since Siri supports devices added through HomeKit, this means that with Homebridge you can ask Siri to control devices that don't have any support for HomeKit at all. For instance, using just some of the available plugins, you can say:

  • Siri, unlock the back door. [pictured to the right]
  • Siri, open the garage door.
  • Siri, turn on the coffee maker.
  • Siri, turn on the living room lights.
  • Siri, good morning!

You can explore all available plugins at the NPM website by searching for the keyword homebridge-plugin.

Community

The official Homebridge Discord server and Reddit community are where users can discuss Homebridge and ask for help.

Homebridge Discord Homebridge Reddit

HomeKit communities can also be found on both Discord and Reddit.

Installation

The Homebridge Wiki contains step-by-step instruction on how to install Node.js and setup Homebridge as a service so it automatically starts on boot:

Quick Overview

  1. Node v10.17.0 or greater is required. Check by running: node -v. The plugins you use may require newer versions.
  2. Install Homebridge using: npm install -g --unsafe-perm homebridge
  3. Install the plugins using: npm install -g <plugin-name>
  4. Create the config.json file.

Installation Details

Homebridge is published through NPM and should be installed "globally" by typing:

sudo npm install -g --unsafe-perm homebridge

Now you should be able to run Homebridge:

$ homebridge
No plugins found. See the README for information on installing plugins.

Homebridge will complain if you don't have any Plugins installed, since it will essentially be useless, although you can still "pair" with it. See the next section "Installing Plugins" for more info.

Once you've installed a Plugin or two, you can run Homebridge again:

$ homebridge
Couldn't find a config.json file [snip]

However, Homebridge won't do anything until you've created a config.json file containing your accessories and/or platforms. You can start by copying and modifying the included config-sample.json file which includes declarations for some example accessories and platforms. Each Plugin will have its own expected configuration; the documentation for Plugins should give you some real-world examples for that plugin.

NOTE: Your config.json file MUST be inside of .homebridge, which is inside of your home folder. On macOS and Linux, the full path for your config.json would be ~/.homebridge/config.json. Any error messages will contain the exact path where your config is expected to be found.

REALLY IMPORTANT: You must use a "plain text" editor to create or modify config.json. Do NOT use apps like TextEdit on macOS or Wordpad on Windows. Apps like these will corrupt the formatting of the file in hard-to-debug ways, making improper " signs is an example. I suggest using the free Atom text editor.

Once you've added your config file, you should be able to run Homebridge again:

$ homebridge
Loaded plugin: homebridge-lockitron
Registering accessory 'Lockitron'
---
Loaded config.json with 1 accessories and 0 platforms.
---
Loading 0 platforms...
Loading 1 accessories...
[Back Door] Initializing Lockitron accessory...

Homebridge is now ready to receive commands from iOS.

Installing Plugins

Plugins are Node.js modules published through NPM and tagged with the keyword homebridge-plugin. They must have a name with the prefix homebridge-, like homebridge-mysmartlock.

Plugins can publish Accessories and/or Platforms. Accessories are individual devices, like a smart switch or a garage door. Platforms act like a single device but can expose a set of devices, like a house full of smart lightbulbs.

You install Plugins the same way you installed Homebridge - as a global NPM module. For example:

sudo npm install -g homebridge-lockitron

You can explore all available plugins at the NPM website by searching for the keyword homebridge-plugin.

Adding Homebridge to iOS

  1. Open the Home app on your device.
  2. Tap the Home tab, then tap .
  3. Tap Add Accessory, then scan the QR code shown in the Homebridge UI or your Homebridge logs.

If the bridge does not have any accessories yet, you may receive a message saying Additional Set-up Required, this is ok, as you add plugins they will show up in the Home app without the need to pair again (except for Cameras and TVs).

Cameras and most TV devices are exposed as separate accessories and each needs to be paired separately. See this wiki article for instructions.

Interacting with your Devices

Once your device has been added to HomeKit, you should be able to tell Siri to control your devices. However, realize that Siri is a cloud service, and iOS may need some time to synchronize your device information with iCloud.

One final thing to remember is that Siri will almost always prefer its default phrase handling over HomeKit devices. For instance, if you name your Sonos device "Radio" and try saying "Siri, turn on the Radio" then Siri will probably start playing an iTunes Radio station on your phone. Even if you name it "Sonos" and say "Siri, turn on the Sonos", Siri will probably just launch the Sonos app instead. This is why, for instance, the suggested name for the Sonos accessory is "Speakers".

Plugin Development

The https://developers.homebridge.io website contains the Homebridge API reference, available service and characteristic types, and plugin examples.

For a great introduction to writing plugins with some example code, check out Frédéric Barthelet's excellent blog post.

There are many existing plugins you can study; you might start with the Homebridge Example Plugins. The Homebridge Plugin Template project also provides a base you can use to create your own platform plugin.

When writing your plugin, you'll want Homebridge to load it from your development directory instead of publishing it to npm each time. Run this command inside your plugin project folder so your global install of Homebridge can discover it:

npm link

You can undo this using the npm unlink command.

Then start Homebridge in debug mode:

homebridge -D

This will start up Homebridge and load your in-development plugin. Note that you can also direct Homebridge to load your configuration from somewhere besides the default ~/.homebridge, for example:

homebridge -D -U ~/.homebridge-dev

This is very useful when you are already using your development machine to host a "real" Homebridge instance (with all your accessories) that you don't want to disturb.

Common Issues

My iOS App Can't Find Homebridge

Two reasons why Homebridge may not be discoverable:

  1. Homebridge server thinks it's been paired with, but iOS thinks otherwise. Fix: deleted persist/ directory which is next to your config.json.

  2. iOS device has gotten your Homebridge username (looks like a MAC address) "stuck" somehow, where it's in the database but inactive. Fix: change your username in the "bridge" section of config.json to be some new value.

  3. iOS DNS cache has gone stale or gotten misconfigured. Fix: Turn airplane mode on and back off to flush the DNS cache. (This is a temporary fix, but can be repeated when the problem recurs. No permanent fix is as yet known/confirmed. If you're experiencing this as a recurrent issue, it likely affects other bonjour and .local DNS resolution services, for which cycling airplane mode will also temporarily resolve.)

Limitations

  • One installation of Homebridge can only expose 150 accessories due to a HomeKit limit. You can however run multiple Homebridge instances by pointing them to different config and persistence paths (see issue #827).
  • Once an accessory has been added to the Home app, changing its name via Homebridge won't be automatically reflected in iOS. You must change it via the Home app as well.

Why Homebridge?

Technically, the device manufacturers should be the ones implementing the HomeKit API. And I'm sure they will - eventually. When they do, this project will be obsolete, and I hope that happens soon. In the meantime, Homebridge is a fun way to get a taste of the future, for those who just can't bear to wait until "real" HomeKit devices are on the market.

Credit

Homebridge was originally created by Nick Farina.

The original HomeKit API work was done by Khaos Tian in his HAP-NodeJS project.

homebridge's People

Contributors

nfarina avatar khaost avatar supereg avatar oznu avatar donavanbecker avatar snowdd1 avatar sphtkr avatar maddox avatar justme-1968 avatar straccio avatar alistairg avatar kraigm avatar stephenyeargin avatar dotsam avatar plasticrake avatar stipus avatar madmod avatar rodtoll avatar ilcato avatar spacecowgirl314 avatar webdeck avatar northernman54 avatar bezzers avatar sweidinger avatar thkl avatar edc1591 avatar cosmo avatar iraven avatar mxdanger avatar schmittx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.