Skip to content
My Account

Software

Homebridge Plugin for an HTTP Switch

A Homebridge plugin that calls a web address to switch a device on and off, and shows it as a switch in the Home app.

  • Homebridge
  • Archived
  • 2 min read
No ratings yet, be the first.

Archived project

The GitHub repository for this project is archived: it is read-only and no longer updated. What follows describes the project as it was, so check for a newer alternative before you build it.

A Homebridge plugin that turns an HTTP device into a switch in the Home app. It is the simplest kind of accessory: the plugin calls a web address when you switch, and the device on the other side does the work.

Homebridge is a program that runs on a computer such as a Raspberry Pi, and makes devices that do not support HomeKit show up in the Apple Home app. This project dates from the Homebridge years, before the native HomeKit firmware of this site. For how the site builds HomeKit devices today, see HomeKit or Matter for your ESP32.

How it works

The plugin calls the same address for both the on and the off state. It expects the device that receives the request to flip its state on every call. The answer has to be a JSON body for every HTTP status code up to 400. For a status code above 400 the plugin throws the body away and treats the answer as an error.

Install and configure

  1. Install Homebridge with npm install -g homebridge.
  2. Install the plugin with npm install -g homebridge-switch.
  3. Add the accessory to the configuration file of Homebridge.
"accessories": [
  {
    "accessory": "HTTP-SWITCH",
    "name": "Living Room switch",
    "url": "http://192.168.1.210/switch",
    "default_state_off": true,
    "sendimmediately": "",
    "http_method": "GET"
  }
]

Replace the address with the address of your own device.

Good to know

  • The package is called homebridge-switch, with the description “Homebridge plugin to control a wall switch”. The README calls it homebridge-http-simple-switch.
  • The repository is under the ISC licence.
  • Apple, HomeKit and Homebridge are trademarks of their owners. This project is not made or approved by them.

The project is in the HomeBridge-Switch repository on GitHub.

Advertisement
All projects

More projects

Keep building.

Electronics, 3D printing and CNC builds, documented from the first idea to the last screw.

All projects