homebridge-dirigera-power-switch
v1.2.1
Published
Virtual Homebridge switch based on Dirigera outlet power consumption
Maintainers
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 resetsRequirements
- 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-switchOr 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": trueEvery 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 / 120sWatch 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
devicesarray will automatically unregister its accessory from Homebridge on the next restart.
License
MIT
