npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-http-curtain

v1.5.0

Published

HTTP curtain or window blinds for Homebridge

Downloads

10

Readme

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:

  • Set target position (0-100).
  • Position change updates: push (efficient / less network and Homebridge load) or pull (easy to configure).
  • Retrieve current position.
  • Send identify request (via Eve Home app) to locate your curtain.

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:

  • name <string> required: Defines the name which is later displayed in HomeKit
  • getCurrentPosUrl <string | urlObject> required: Defines the url (and other properties when using an urlObject) to query the current position from the curtain. It expects the http server to return a integer ranging from 0-100 (step 1) leaving out any html markup when no getCurrentPosRegEx is provided.
  • getCurrentPosRegEx <string> optional: A regular expression from which the first matched group determines the current position.
  • getPositionStateUrl <string | urlObject> optional: Defines the url (and other properties when using an urlObject) to query the current state from the curtain. It expects the http server to return a integer '0' (Closing), '1' (Opening) or '2' (Idle) leaving out any html markup. Note that Homekit ignores this state as it rather compares CurrentPosition with TargetPosition.
  • setTargetPosUrl <string | urlObject> required: Defines the url (and other properties when using an urlObject) to set the target position at the curtain. Any %d format specifier will be replaced by the requested target position.
  • getTargetPosUrl <string | urlObject> optional: Defines the url (and other properties when using an urlObject) to retrieve the target position at the curtain.
  • getTargetPosRegEx <string> optional: A regular expression from which the first matched group determines the target position.
  • identifyUrl <string | urlObject> optional: URL to call when the HomeKit identify action is requested.
  • pullInterval <integer> optional: The property expects an interval in milliseconds in which the plugin pulls updates from your http device. For more information read pulling updates.
  • invertPosition <boolean> optional: True: interpret 0% as fully open and 100% as fully closed.

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:

  • url <string> required: Defines the url pointing to your http server
  • method <string> optional (Default: "GET"): Defines the http method used to make the http request
  • body <string> optional: Defines the body sent with the http request
  • auth <object> optional: If your http server uses basic authentication you can specify your credential in this object. When defined the object must contain the following properties:
    • username <string>
    • password <string>
  • headers <object> optional: Using this object you can define any http headers which are sent with the http request. The object must contain only string key value pairs.

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"
        }   
    ]
}
  • notificationID is an per Homebridge instance unique id which must be included in any http request.
  • notificationPassword is optional. It can be used to secure any incoming requests.

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

  • characteristic "CurrentPosition": expects an integer value in a range of 0 up to and including 100.