HTTP Switch with optionnal webhook support for HomeBridge

Usage no npm install needed!

<script type="module">
  import homebridgeHttpSwitchWebhook from 'https://cdn.skypack.dev/homebridge-http-switch-webhook';



npm npm


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.



npm install -g homebridge-http-switch-webhook


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"


  • 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.