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

v0.1.0

Published

An example accessory plugin for programmable http services

Downloads

3

Readme

homebridge-http-prog

This is an accessory plugin for the Homebridge. The plugin enables you to choose how your HTTP request should look like. It is currently in development and does not support retrieving a state yet. However, it will be implemented soon. If you have any suggestions for improvements or implementations, don't hesitate to send me a message.
NOTE: Because this is a WOK (WorkInProgress) it only implements a switch with the ability to change color. Other devices than RGB Lights will be implemented in the future.

How to install

Open up your Homeridge in the browser, go to the plugins page and just search for homebridge-http-prog. Don't have a Homebridge? Follow these instructions.
If you wish to install this plugin manually, open up your Terminal and type in:

npm install -g homebridge-http-prog

Make sure to use the global tag -g since Homebridge only reads globally installed packages.

How to implement this plugin?

Once you installed the plugin via Homebridge, go to your configuration page and add the following:

"accessories": [{
        "accessory": "http-prog",
        "name": "Programmable HTTP",
        "send_state": {},
        "send_update": {}
        }],

Change the value of "name" to whatever you wish the plugin to be displayed as. Please look at the Syntax section to configure the plugin

Syntax

Here is a list of all the properties that can be declared.

  • bulb_on (string, default: "on") The string when the bulb is set on. This is important if the device is listening to a specific key other than "on".
  • bulb_off (string, default: "off") The string when the bulb is set off. This is important if the device is listening to a specific key other than "off".
  • send_state (object, must implement) Object that will be called when the state of the bulb changes (either on or off). It contains the following properties:
    • http_method (string, default "GET") The method to be used.
    • url (string, default: "http://localhost") The url to send the request to.
      • %s This sequence is being reserved as a placeholder for the state. It can be implemented at any point in the url and will be parsed as bulb_on or bulb_off. Make sure to implement it as a string (see example).
    • port (number, default: 80) The port to send the request to.
    • headers (JSON, default: null) Some custom headers to send. It accepts any values. For further information read Wikipedia - Headers. Placeholders here will not be parsed.
    • body (JSON/string, default: null) The body of the request. I can contain anything you want to be transmitted.
  • send_update (object, must implement) Object that will be called when the RGB of the bulb updates .it contains the following properties: (similar to send_state)
    • http_method (similar to send_state)
    • url (similar to send_state)
      • %r, %g, %b, This sequence is being reserved as a placeholder for the values of R, G, B. It can be implemented at any point in the url and will be parsed as a number from 0 to 255. Make sure to implement it as a string (see example).
    • port (similar to send_state)
    • headers (similar to send_state) Placeholders here will not being parsed.
    • body (JSON, default: null) The body of the request.
      • %r,%g,%b Like the %s, These placeholders are being reserved for RGB values. They can be placed anywhere in the body. Make sure to implement them as a string (see example).
  • get (object, default: null) Coming soon...

NOTE: Defining properties in send_state (for example url), does not automatically change the properties send_update

Example

In this example I use the following configuration for my Arduino Uno Wifi rev 2. The code uploaded on the board can be found here.

"accessories": [{
        "accessory": "http-prog",
        "name": "Programmable HTTP",
        "send_state": {
            "url": "http://192.168.x.x/api/send",
            "body": {
                "state": '%s'
            }
        },
        "send_update": {
            "url": "http://192.168.x.x/api/send",
            "body": {
                "r": '%r',
                "g": '%g',
                "b": '%b'
            }
        }
        }],

If you have any suggestions for improvement, don't hesitate sending me a message :)