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 🙏

© 2026 – Pkg Stats / Ryan Hefner

homebridge-restart-switch

v1.0.4

Published

Expose a HomeKit switch that restarts Homebridge, with accessory info fields (hostname, IP, versions) doubling as a status readout.

Readme

homebridge-restart-switch

A HomeKit switch that restarts Homebridge, with the accessory's info fields doubling as a status readout — hostname, LAN IP, Homebridge/Node versions, and an optional device ID you assign (shown as the Model field, so it's visible at a glance in the Home app's Home Hubs & Bridges list).

Install

This is a Homebridge platform plugin. On a Config UI X install where plugins are scoped to a per-instance folder (check for UIX_CUSTOM_PLUGIN_PATH in the Homebridge process environment — grep UIX_CUSTOM_PLUGIN_PATH /proc/<homebridge-pid>/environ), install into that folder rather than globally:

npm run build
npm pack
cd /var/lib/homebridge   # or wherever UIX_CUSTOM_PLUGIN_PATH points
npm install /path/to/homebridge-restart-switch-1.0.0.tgz --save

A plain global install (npm install -g) will build without error but Homebridge won't discover the plugin under a strict-plugin-resolution Config UI X setup — it has to land inside the instance's own node_modules.

Restart Homebridge once manually afterwards to pick it up.

Configure

In Homebridge UI → Plugins → Homebridge Restart Switch → Settings, or add directly to config.json under platforms:

{
  "platforms": [
    {
      "platform": "HomebridgeRestartSwitch",
      "name": "Restart Homebridge",
      "deviceId": "site-0123",
      "restartMethod": "systemd",
      "useSudo": true,
      "serviceName": "homebridge",
      "confirmWindowSeconds": 15,
      "restartDelaySeconds": 2
    }
  ]
}

restartMethod options

  • auto (default) — detects hb-service or PM2 from environment variables, otherwise assumes systemd.
  • hb-service — runs hb-service restart (Homebridge Config UI X).
  • systemd — runs systemctl restart <serviceName> (default service name homebridge). This is the recommended option when Homebridge runs as a systemd service with Restart=always — the switch tells systemd to restart, systemd brings the process back.
  • pm2 — runs pm2 restart <pm2ProcessName>.
  • custom — runs whatever you put in customCommand.
  • exit — just calls process.exit() and relies entirely on whatever supervises the process to relaunch it. Note this plugin always runs as an isolated HomeKit child bridge (a separate forked subprocess), so process.exit() only kills that subprocess — it will NOT restart the main Homebridge process. Use systemd/hb-service/pm2 instead unless you specifically want to recycle just this plugin's own process.

Every path ends by calling process.exit() a couple of seconds after the exec'd command, as a fallback in case that command didn't already tear the process down.

If your restart command needs elevated privileges, set useSudo: true and make sure the user Homebridge runs as can run that specific command via sudo without a password prompt — a narrow visudo NOPASSWD entry scoped to just systemctl restart homebridge, not blanket sudo.

Using it in Apple Home

The switch shows as On while Homebridge is running normally. Turning it off triggers the restart; it flips back to on on its own a moment later while the actual restart happens a couple of seconds after that — treat it as a momentary control, not a persistent state. Because it's a real HomeKit accessory (not a direct connection to the Pi), it works the same over Wi-Fi or via remote access through your Home Hub, with no need for your phone to reach the Pi directly.

Open the accessory's details page in Home (or the Eve app, which shows more fields) to see:

  • Model — the ID you assigned in deviceId (or the hostname if you left it blank), so you can tell several Pis apart at a glance in the Home Hubs & Bridges list. Configs that still use the old oncueHomeId name keep working.
  • Serial Number — hostname, LAN IP, and Homebridge/Node versions, for deeper troubleshooting.

Safety notes

  • The switch re-arms itself after confirmWindowSeconds in case the restart didn't actually happen (e.g. no process-manager restart policy configured) — otherwise a failed restart would leave the switch permanently unresponsive.
  • Test your chosen restartMethod manually on the Pi first (systemctl restart homebridge, hb-service restart, etc.) before wiring it up to the switch, so you know it actually comes back.
  • This plugin is built on the Platform API (DynamicPlatformPlugin), not the legacy single-Accessory API — on at least one Homebridge v2.4.0/hb-service setup, a legacy-API build of this same plugin hit an indefinite "Setting Up" spinner when pairing in the Home app. That turned out to be unrelated (an iOS/tvOS 27 HomeKit bug, since fixed by Apple), but the Platform API is the well-trodden path every other plugin on a typical instance already uses, so it's kept that way.

Restart history

Since 1.0.4 the plugin keeps a short history of restarts in Homebridge's storage folder (restart-switch-log.json, the last 200 entries): every tap of the switch, and every Homebridge start. A start that follows a tap within five minutes counts as "from the switch"; any other start is a restart from something else (a crash, an update or a reboot). Each start writes one line to the log, for example Homebridge started. Last 7 days: 3 starts (1 from the switch, 2 other). Nothing leaves the Pi.