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-dirigera-power-switch

v1.2.1

Published

Virtual Homebridge switch based on Dirigera outlet power consumption

Readme

homebridge-dirigera-power-switch

A Homebridge plugin that exposes virtual switch accessories whose state is driven by the real-time power consumption of outlets connected to an IKEA Dirigera hub.

When an outlet's wattage crosses a configurable threshold the switch turns on. When consumption drops below a second (lower) threshold and stays there for a configurable delay, the switch turns off. This hysteresis logic prevents the switch from flipping rapidly when a device idles near the boundary (e.g. a washing machine between cycles).

Use the virtual switches in HomeKit automations — for example, send a notification when the washing machine finishes, or trigger a scene when the coffee maker starts brewing.

How it works

power ≥ thresholdOn  →  switch turns ON  (immediately)
power < thresholdOff →  start off-timer
off-timer ≥ offDelaySec  →  switch turns OFF
power rises back above thresholdOff before timer expires  →  timer resets

Requirements

  • Homebridge ≥ 1.6.0
  • Node.js ≥ 18
  • An IKEA Dirigera hub with at least one smart outlet that reports power consumption

Installation

npm install -g homebridge-dirigera-power-switch

Or install via the Homebridge UI by searching for homebridge-dirigera-power-switch.

Configuration

Add a platform entry to your Homebridge config.json. The hub credentials (host, token) are specified once at the top level and shared across all devices. Each outlet gets its own entry in the devices array with its own display name and threshold settings.

{
  "platforms": [
    {
      "platform": "DirigeraPowerSwitch",
      "name": "Dirigera Power Switch",
      "host": "192.168.1.50",
      "token": "<your-dirigera-token>",
      "configMode": false,
      "devices": [
        {
          "name": "Washing Machine",
          "deviceId": "<outlet-device-id>",
          "thresholdOn": 5,
          "thresholdOff": 2,
          "offDelaySec": 120,
          "pollIntervalSec": 10
        },
        {
          "name": "Dishwasher",
          "deviceId": "<outlet-device-id>",
          "thresholdOn": 10,
          "offDelaySec": 60
        }
      ]
    }
  ]
}

Platform parameters

| Parameter | Required | Default | Description | |---|---|---|---| | name | no | "Dirigera Power Switch" | Platform name (internal, not shown in HomeKit) | | host | yes | — | IP address or hostname of your Dirigera hub | | token | yes | — | Dirigera API bearer token | | configMode | no | false | When true, logs every poll for all devices at info level to help calibrate thresholds (see below) | | devices | yes | — | Array of outlets to monitor (see below) |

Per-device parameters

| Parameter | Required | Default | Description | |---|---|---|---| | name | yes | — | Accessory name shown in HomeKit | | deviceId | yes | — | Device ID of the outlet to monitor | | thresholdOn | no | 5 | Watts above which the switch turns on | | thresholdOff | no | 2 | Watts below which the off-timer starts | | offDelaySec | no | 120 | Seconds the power must stay below thresholdOff before turning off | | pollIntervalSec | no | 10 | How often (in seconds) the Dirigera API is polled |

Getting your Dirigera token and device ID

Token

The Dirigera hub exposes a local REST API secured with a bearer token. You can obtain the token by completing the one-time pairing flow with the hub. Several community tools automate this — for example the dirigera npm package or the python-dirigera library both include a pairing command.

Once paired, the token is a long-lived credential you paste into the config above.

Device ID

After you have the token, query the hub's device list to find the outlet:

curl -sk https://<hub-ip>:8443/v1/devices \
  -H "Authorization: Bearer <token>" | jq '.[] | select(.type == "outlet") | {id, name: .attributes.customName}'

Copy the id value for each outlet you want to monitor and use it as deviceId.

Calibrating thresholds

If you're unsure what values to use for thresholdOn and thresholdOff, enable configMode at the platform level:

"configMode": true

Every poll will then log a line like this for each device:

[Washing Machine] [CONFIG MODE] power=1847W | state=ON | thresholdOn=5W thresholdOff=2W offDelaySec=120s
[Washing Machine] [CONFIG MODE] power=0.4W | state=ON | thresholdOn=5W thresholdOff=2W offDelaySec=120s | below-threshold for 34s / 120s

Watch the power values while the appliance runs through its full cycle — note the idle/standby wattage between phases — then set thresholdOff below that idle level. Disable configMode once you're happy with the values.

Notes

  • The Dirigera hub uses a self-signed TLS certificate. The plugin disables TLS verification (NODE_TLS_REJECT_UNAUTHORIZED=0) so the connection works out of the box. Only use this plugin on a trusted local network.
  • Switch state is driven entirely by power consumption. Manual toggles in HomeKit are ignored; the next poll will restore the correct state.
  • Removing a device from the devices array will automatically unregister its accessory from Homebridge on the next restart.

License

MIT