Registry / automation / harmony-websocket

harmony-websocket

JSON →
library1.5.5jsnpmunverified

A Node.js WebSocket client for Logitech Harmony Hub, version 1.5.5. Provides a simple event-driven API to send commands, retrieve activities, devices, and configuration. Low release cadence (sporadic). Differentiates from other Harmony libraries by focusing solely on WebSocket communication with minimal dependencies. Supports CommonJS only.

npm install harmony-websocket
INSTALL
IMPORT
SIG · HARMONY-WEBSOCKET
H
harmony-websocket
automationjavascriptv1.5.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Harmony
const { Harmony } = require('harmony-websocket')
const Harmony = require('harmony-websocket'); // yields undefined if expecting default export
As of v1.5.5, the package exports { Harmony } via CommonJS. Using require without destructuring results in undefined.
Harmony
import { Harmony } from 'harmony-websocket'
ESM import works only if package supports it (check package.json). As of v1.5.5, there is no ESM entry point.

Connect to a Harmony Hub and list activities using the Harmony WebSocket client.

const { Harmony } = require('harmony-websocket'); const harmony = new Harmony(); harmony.on('open', () => console.log('open')); harmony.connect('192.168.1.10') .then(() => harmony.getActivities()) .then(activities => console.log(activities)) .catch(err => console.error(err.message));
Debug
Known issues
gotchaRequire destructured import: const { Harmony } = require('harmony-websocket'). Using const Harmony = require('harmony-websocket') yields undefined.
fix
Use const { Harmony } = require('harmony-websocket')
affects: >=1.0.0
gotchaESM import not supported. Package does not expose a module entry point.
fix
Use CommonJS require or wait for future version.
affects: >=1.0.0
gotcha.connect() returns a Promise, but the package does not handle connection failures gracefully.
fix
Always attach a .catch() handler to .connect().
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Harmony is not a constructor
Improper import: used const Harmony = require('harmony-websocket') which yields an object, not a constructor.
fix
Use const { Harmony } = require('harmony-websocket')
Cannot find module 'harmony-websocket'
Package not installed or misspelled.
fix
Run npm install harmony-websocket
TypeError: harmony.connect is not a function
Harmony instance not created properly, perhaps due to wrong import.
fix
Ensure you use new Harmony() after correct import.
Upgrade
Version history
1.5.5latest on npm
Audit
Dependencies
wsrequiredWebSocket client library
Agent activity
43 hits · last 30 days
node
36
Resources
harmony-websocket — npm install harmony-websocket · libregistry