QuickSander / homebridge-http-curtain

Homebridge plugin to operate web based/http curtains with push position updates.
Other
2 stars 3 forks source link

Build Status semantic-release npm version verified-by-homebridge

homebridge-http-curtain

This Homebridge plugin can be used to integrate your curtain which has an HTTP api into HomeKit. This controller supports push notification without the need for HomeBridge to periodically pull the curtain position value. There are a few other HTTP based curtain / window blinds plugins available, but I have not found any yet that does not poll the curtain controller continuously for position or state updates.

This is a fork of Supereg's homebridge-http-temperature-sensor modified to function as an curtain controller.

Features:

Installation

First of all you need to have Homebridge installed. Refer to the repo for instructions.
Then run the following command to install homebridge-http-curtain

sudo npm install -g homebridge-http-curtain

Updating the curtain position in HomeKit

The 'CurrentPosition' characteristic from the 'WindowCovering' service has the permission to notify the HomeKit controller of state changes. homebridge-http-curtain supports two ways to send window blinds/curtain position changes to HomeKit.

The 'pull' way:

The 'pull' way is probably the easiest to set up and supported in every scenario. homebridge-http-curtain requests the value of the curtain/window blind in an specified interval (pulling) and sends the value to HomeKit.
Look for pullInterval in the list of configuration options if you want to configure it.

The 'push' way:

When using the 'push' concept the HTTP device itself sends the updated value itself to homebridge-http-curtain whenever the value changes. This is more efficient as the new value is updated instantly and homebridge-http-curtain 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-curtain plugin there is more work needed to implement this method into your http device.
How to implement the protocol into your http device can be read in the chapter Notification Server

Configuration

The configuration can contain the following properties:

Below is an example configuration. One URL is using a simple string URL and the other is using an urlObject.
Both configs can be used for a basic plugin configuration.

{
    "accessories": [
        {
          "accessory": "HttpCurtain",
          "name": "Living Room Left Curtain",

          "getCurrentPosUrl": "http://livingroom-curtain-left/api/v1/pos",
          "setTargetPosUrl": {
            "url": "http://livingroom-curtain-left/api/v1/pos/%d",
            "method": "PUT"
          }
        }   
    ]
}

UrlObject

A urlObject can have the following properties:

Below is an example of an urlObject containing all properties:

{
  "url": "http://example.com:8080",
  "method": "GET",
  "body": "exampleBody",

  "auth": {
    "username": "yourUsername",
    "password": "yourPassword"
  },

  "headers": {
    "Content-Type": "text/html"
  }
}

Notification Server

homebridge-http-curtain can be used together with homebridge-http-notification-server in order to receive updates when the state changes at your home automation device. For details on how to implement those updates and how to install and configure homebridge-http-notification-server, please refer to the README of that repository.

Down here is an example on how to configure homebridge-http-curtain to work with your implementation of the homebridge-http-notification-server.

{
    "accessories": [
        {
          "accessory": "HttpCurtain",
          "name": "Living Room Curtain",

          "notificationID": "my-curtain",
          "notificationPassword": "SuperSecretPassword",

          "getUrl": "http://localhost/api/pos"
        }   
    ]
}

To get more details about the configuration have a look at the README.

Available characteristics (for the POST body)

Down here are all characteristics listed which can be updated with an request to the homebridge-http-notification-server