homebridge-rabbitmq

1.0.13 • Public • Published

Since RabbitMQ messaging protocol is very easy to implement in just any language (Pyton, Java, Javascript, Rubi, Php, Swift...), I made this plugin so you can easily connect HomeBridge (HomeKit) with your own app.

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install homebridge-rabbitmq using: npm install -g homebridge-rabbitmq
  3. Update your configuration file (/home/username/.homebridge/config.json)

Configuration

To add rabbitmq accessories to your homebridge, simply add them to your config.json. Three keys are required:

  • accessory - must be "Rabbitmq"
  • name - something like "Cloe's Lamp"
  • service - Switch, Light or Thermostat

Sample config:

Here's an example of "accessories" in the config.json:

"accessories": [ 
    {
        "accessory":          "Rabbitmq",
        "name":               "Basement Pump",
        "service":            "Switch"
    },
    {
        "accessory":          "Rabbitmq",
        "name":               "Bed Lamp",
        "service":            "Light"
    }
]

Protocol and messages

Homebridge-rabbitmq will post messages to your localhost rabbitmq server - which must be run at all times, otherwise homebridge will crash. The rabbitmq queue name here is "hap".

Messages sent over rabbitmq will look like this: "update {Cloe's Lamp} [80.0]". The first argument is always update followed by «type», then {name} of the accessory, then the , and then the [value]. Bracket characters are here for easier parsing.

List of all possible methods:

  • Switch - powerState
  • Light - powerState, brightness, hue
  • Thermostat - targetHeatingCoolingState, targetTemperature, temperatureDisplayUnits

List of Values

  • PowerState: 0 = off, 1 = on
  • Hue: 0 - 360
  • Brightness: 0 - 100
  • TargetTemperature: any number
  • HeatingCoolingStates: 0 = off, 1 = heat, 2 = cool, 3 = auto
  • TemperatureDisplayUnits: 0 = Celsius, 1 = Fahrenheit

Getting current value of accessory

In your Documents directory, you will find "Homebridge-Accessories" folder. Every value will be saved and updated in its own txt file.

File name: "name_method.txt", ex. "Freezer_targetTemperature.txt"

BONUS: terminal commands

You can execute a terminal command when a Rabbitmq accessory is activated. Just add another key below "service" key. The key is method+"_command". In the value of these keys you can put any terminal command you want (example: "open -a iTunes" or "shutdown") In addition, you can use variables inside those commands. Possible variables are #NAME# and #VALUE#.

Example of executing terminal commands:

"accessories": [ 
    {
        "accessory":          "Rabbitmq",
        "name":               "Bed Lamp",
        "service":            "Light",
        "powerState_command":  "sudo hub-control -port 3 -power #VALUE#",
        "brightness_command":  "sudo gpio pin 3 pwm #VALUE# -g"
    }
]

Readme

Keywords

Package Sidebar

Install

npm i homebridge-rabbitmq

Weekly Downloads

1

Version

1.0.13

License

ISC

Last publish

Collaborators

  • manuel-vrhovac