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-entry

v1.1.2

Published

Homebridge plugin that creates a GarageDoorOpener which uses configurable HTTP calls to set and get its state.

Downloads

8

Readme

homebridge-http-entry

A homebridge accessory to make HTTP calls to garage doors and gates.

Open, close, and get the state of your entry.

Features

  • Configurable endpoints for getting/setting entry state
  • Support for any type of HTTP method (default: GET)
  • Support for HTTP basic auth
  • Configurable mapping of endpoint response body to HomeKit garage door states
  • Supports pulling data from device (polling) or pushing from devices (webhooks)

Install

  • Requires homebridge (npm install -g homebridge).
  • Requires Node >= 8.11
npm install -g homebridge-http-entry

Usage

Update your homebridge configuration file with a new block under accessories.

Property | Type | Default | Description ---------|------|------|-------- accessory | string | | (Required) HttpEntry name | string | | (Required) The name of your accessory. enableDebugLog | bool | false | Enable extra debug logging. auth.username | string | | HTTP auth username auth.password | string | | HTTP auth password webhooks.accessoryId | string | | A unique id for notification server urls webhooks.password | string | | An optional password for notification server requests pollInterval | number | | Interval to poll in milliseconds. Ignored if used with webhooks.accessoryId endpoints | object | | Supports getState, open, close. See Endpoint Configuration for details mappers | object | | Supports static, regex, and xpath. See Mappers for usage.

Example config (minimal)

{
  "accessory": "HttpEntry",
  "name": "Garage Bay 1",
  "endpoints": {
    "getState": {
      "method": "GET",
      "url": "http://bay1.local/state",
    },
    "open": {
      "method": "PUT",
      "url": "http://bay1.local/state",
      "body": "OPEN"
    },
    "close": {
      "method": "PUT",
      "url": "http://bay1.local/state",
      "body": "CLOSED"
    }
  }
}

Endpoint Configuration

Endpoint configuration is passed directly to got. Minimally url makes this useful, but you may also craft requests with PUT or POST methods.

Example:

{
  "url": "http://bay1.local/state",
  "method": "PUT",
  "body": "OPEN",
}

You may define any of the following endpoints:

  • getState
  • open
  • close
  • cycle

Advanced

Mappers

Mappers may be applied to the endpoint response to transform it into the numeric states expected by HomeKit. The GarageDoorOpener service expects one of the following states:

Value | State ----|---- 0 | open 1 | closed 2 | opening 3 | closing 4 | stopped

Mappers are applied in order, with the result of the previous passed to the next. Use the mappers property to configurare mappers for your accessory.

Static

Map one value to another

Example configuration:

{
  "type": "static",
  "parameters": {
    "mapping": {
      "OPENING": 2,
      "CLOSING": 3
    }
  }
}

Example response:

OPENING

Output:

2

Regex

Capture output a regular expression

Example configuration:

{
  "type": "regex",
  "parameters": {
    "regexp": "^The door is currently (OPEN|CLOSED), yo!$",
    "captureGroup": 1
  }
}

Example response

The door is currently OPEN, yo!

Output:

OPEN

XPath

Capture output XML using XPath expressions

{
  "type": "xpath",
  "parameters": {
    "xpath": "//dd/text()",
    "index": 0
  }
}

Example response:

<main>
  <h1>Door</h1>
  <dl>
    <dt>State</dt>
    <dd>OPENING</dd>
  </dl>
</main>

Output:

OPENING

Webhooks

This accessory supports receiving updates via webhooks using homebridge-http-notification-server as a more efficient alternative to polling. Use the webhooks configuration to receive state updates from your accessory.

  1. Install and configure homebridge-http-notification-server.
  2. Add webhooks configuration to this accessory.
  3. Configure your sender

Example webhooks config:

{
  "webhooks": {
    "accessoryId": "bay1"
  }
}

Example sender configuration:

{
  "characteristic": "TargetDoorState",
  "value": 1
}

value should reflect the current door state (0-4).

Developing

Testing

See https://github.com/homebridge/homebridge#plugin-development

  1. yarn test
  2. yarn watch
  3. Configure homebridge from ~/.homebridge
  4. yarn http-server and edit response from TestGateAccessory
  5. Use an http client to create requests to notification server

Example:

POST http://127.0.0.1:8081
{
    "characteristic": "CurrentDoorState",
    "value": "1",
    "accessory": "gate"
}

License

ISC