homebridge-http-switch-webhook

1.0.0 • Public • Published

homebridge-http-switch-webhook

npm npm

Description

This Project deliver a simple, but fail-safe HTTP Switch for HomeBridge with optionnal support for webhook with or without conjuction of polling.

To simplify the webhook, it listens on a port and simply triggers the "status_url" parameter on request. So it needs no parameters.

http://homebridge_ip:webhook_port

Installation

npm install -g homebridge-http-switch-webhook

config.json

The following paramteres are supported:

    // Switch with polling and a On/Off-State
    {
      "accessory" : "SimpleHttpSwitch",
      "http_method" : "GET",                              // The HTTP-Method
      "ignore_https_security" : false                     // Should the HTTPS Certificate (for all https requests) be validated? (Set it to true if you are using a self-signed cert)
      "set_off_url" : "http://localhost/turn/off",        // The JSON-Webservice URL for turning the device on
      "status_url" : "http://localhost/device/status",    // The JSON-Webservice URL for getting the device's status
      "on_if_this_fn" : "(obj)=>obj.status ? obj.status=='ON' : null", //JS Function for evaluating if the device is on, you can alternativly use the following:
      "on_if_this": {"status":"on"},                      // If you don't want to use on_if_this_fn
      "off_if_this": {"status":"off"},                    // If you don't want to use on_if_this_fn
      "set_on_url" : "http://localhost/turn/on",          // The JSON-Webservice URL for turning the device on
      "polling" : true,                                   // Enable Polling/Refreshing of the Status
      "pollingInterval" : 60,                             // Polling Interval in Seconds
      "name" : "Desk Light",                              // Name of your Switch/Accessory
      "webhook_port" : "3211"                             // (Optionnal) Port to listen for webhook
    }

    // Stateless Switch, will automaticly go off a few miliseconds after switched on
    {
      "accessory" : "SimpleHttpSwitch",
      "set_on_url" : "http://localhost/trigger/something",
      "status_url" : "", // Needs to be empty
      "name" : "Desk Light"
    }

ToDo

  • migrate to a platform instead of a single accessory
  • support other HomeKit-Accessories then 'Switch'
  • migrate to another web server than the now deprecated "express" one.

Credits

https://github.com/sinnaj-r/homebridge-simple-http

Package Sidebar

Install

npm i homebridge-http-switch-webhook

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

10.6 kB

Total Files

5

Last publish

Collaborators

  • lejeko