Powerful http lightbulb for Homebridge: https://github.com/nfarina/homebridge
homebridge-http-lightbulb
is a Homebridge plugin with which you can configure
HomeKit light bulbs which forward any requests to a defined http server. This comes in handy when you already have home
automated equipment which can be controlled via http requests. Or you have built your own equipment, for example some sort
of lightning controlled with an wifi enabled Arduino board which than can be integrated via this plugin into Homebridge.
First of all you need to have Homebridge installed. Refer to the repo for
instructions.
Then run the following command to install homebridge-http-lightbulb
sudo npm install -g homebridge-http-lightbulb
All characteristic from the ‘lightbulb’ service have the permission to notify
the HomeKit controller of state
changes. homebridge-http-lightbulb
supports two concepts to send state changes to HomeKit.
The ‘pull’ way is probably the easiest to set up and supported in every scenario. homebridge-http-lightbulb
requests the
state of the light in an specified interval (pulling) and sends the value to HomeKit.
However the pull way is currently only supported for the ‘On’ characteristic!
Look for pullInterval
in the list of configuration options if you want to configure it.
When using the ‘push’ concept, the http device itself sends the updated value to homebridge-http-lightbulb
whenever
values change. This is more efficient as the new value is updated instantly and homebridge-http-lightbulb
does not
need to make needless requests when the value didn’t actually change.
However because the http device needs to actively notify the homebridge-http-lightbulb
there is more work needed
to implement this method into your http device.
MQTT (Message Queuing Telemetry Transport) is a protocol widely used by IoT devices. IoT devices can publish messages
on a certain topic to the MQTT broker which then sends this message to all clients subscribed to the specified topic.
In order to use MQTT you need to setup a broker server (mosquitto is a solid
open source MQTT broker running perfectly on a device like the Raspberry Pi) and then instruct all clients to
publish/subscribe to it.
For those of you who are developing the http device by themselves I developed a pretty simple ‘protocol’ based on http
to send push-updates.
How to implement the protocol into your http device can be read in the chapter
Notification Server
The configuration can contain the following properties:
accessory
\name
\onUrl
\offUrl
\statusUrl
\statusPattern
option (see below).statusPattern
\statusUrl
. When matching the status of the light bulb is set to ON otherwise OFF.brightness
\hue
\saturation
\colorTemperature
\auth
\statusCache
\brightnessCache
\hueCache
\saturationCache
\colorTemperatureCache
\pullInterval
\mqtt
\<mqttObject> optional: Defines all properties used for mqtt connection (More on MQTT).debug
\In the Examples section are some example configurations to get you started.
The options in this section are all part of some experimental features and can change in any update.
I’m currently experimenting with allowing setting and querying device status with mqtt alongside http.
So that you are for example able to manage the ON characteristic fully over mqtt and the color and
brightness values over http. Currently this is only supported for the ON characteristic but I’m planning
to add this for any combination of characteristics and in the long run also to get added into my
homebridge-http-switch plugin if everything works well.
setPowerTopic
\topic
\qos
\retain
\dup
\payloadFormatter
\getPowerTopic
\topic
\qos
\messagePattern
\patternGroupToExtract
\setUrl
propertiesOn every set there are the following placeholders available which will be replaced with the respective value.
Note that for example when the setUrl
for the brightness characteristic is called, %s
will be replaced with the
new value and %brightness
will be replaced with the current/old value.
The value for the placeholders will be supplied in the specified unit.
%s
will always be replaced with the new value which will be set for the current characteristic%brightness
- current brightness level%hue
- current hue%saturation
- current saturation%colorTemperature
- current color temperature (case sensitise)A urlObject can have the following properties:
url
\method
\body
\strictSSL
\auth
\headers
\Below is an example of an urlObject containing all properties:
{
"url": "http://example.com:8080",
"method": "GET",
"body": "exampleBody",
"strictSSL": false,
"auth": {
"username": "yourUsername",
"password": "yourPassword"
},
"headers": {
"Content-Type": "text/html"
}
}
A mqttObject can have the following properties:
host
\port
\credentials
\subscriptions
\