Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
harmonyhubws
Advanced tools
Simple API for Logitech Harmony Hub using local Websocket Connection
A node module for Logitech Harmony Hub.
Uses a simple watchdog to reconnect on connection losses.
npm install harmonyhubws --production
with Hub IP 192.168.0.50:
const util = require('util');
const HarmonyHubWS = require('harmonyhubws');
const IP = '192.168.0.50';
let harmonyHubWS = new HarmonyHubWS(IP);
harmonyHubWS.on('online', () => {
console.log('connected to hub', IP);
//request config
harmonyHubWS.requestConfig();
});
harmonyHubWS.on('config', (config) => {
//be careful, config could be very big!
console.log('config', util.inspect(config,false, null, true));
//request hub state
harmonyHubWS.requestState();
//if there is a device press first button of device
if (config.device.length) {
let device = config.device[0];
if (device.controlGroup.length && device.controlGroup[0].function.length) {
console.log('pressing key', device.label, device.controlGroup[0].function[0].label);
harmonyHubWS.requestKeyPress(device.controlGroup[0].function[0].action);
}
}
//if there is an activity start it
if (config.activity.length) {
let activity = config.activity[0];
console.log('starting activity', activity.label);
harmonyHubWS.requestActivityChange(activity.id);
}
});
harmonyHubWS.on('state', (activityId, activityStatus) => {
console.log('state', activityId, activityStatus);
//if an activity is started turn it off and close client
if (activityStatus === 2) {
console.log('activity started, turn off', activityId);
harmonyHubWS.requestActivityChange('-1');
harmonyHubWS.close();
}
});
harmonyHubWS.on('offline', () => {
console.log('lost connection to hub', IP);
});
Returns the state object of the robot. Also updates all robot properties.
ip
: string
- IP of your Harmony Hubwatchdog
]: boolean
- defaults to trueconst HarmonyHubWS = require('harmonyhubws');
const IP = '192.168.0.50';
//start client without automatic connection handling
let harmonyHubWS = new HarmonyHubWS(IP, false);
Asks Hub to send Config. To retrieve config use event config
.
Asks Hub to send current state. To retrieve current state use event state
.
Asks Hub to start activity with ID activityId
. Results in multiple state events, activityState
will be 2
when the activity is completely started.
activityId
: number|string
- ID of the activity you want to start, use '-1'
(string!) to turn off any activity. To retrieve activity IDs see requestConfig.Asks Hub to press a device key.
action
: string
- whole action string (deviceId, keyId, type) as retrieved from config.hold
]: string
'press' or 'hold' - defaults to press
, hold
is a long press for ~250ms, if you want to hold longer you need to request hold repeatedly.delay
]: number
defaults to 100
, how long the key is heldor
deviceId
: string
- ID of the device you want to control. To retrieve device IDs see requestConfig.keyId
: string
- ID (name) of the key you want to press. To retrieve key Ids see requestConfig.type
]: number
- defaults to IRCommand
. To retrieve key types see requestConfig.hold
]: string
'press' or 'hold' - defaults to press
, hold
is a long press for ~250ms, if you want to hold longer you need to request hold repeatedly.delay
]: number
defaults to 100
, how long the key is heldFired when connection to hub is established.
Fired when connection to hub is lost.
Fired when hub sends its current state.
activityId
: number|string
- ID of current activity, '-1'
for powerOff.activityState
: number
- state of current activity, where
0
: off1
: starting (hub blocked until activityState is 2)2
: started3
: stopping (hub blocked until activityState is 0)Fired when hub sends its configuration (devices, activities).
config
: object
- Hubs configuration. For details see example.FAQs
Simple API for Logitech Harmony Hub using local Websocket Connection
The npm package harmonyhubws receives a total of 39 weekly downloads. As such, harmonyhubws popularity was classified as not popular.
We found that harmonyhubws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.