Registry / devops / node-red-contrib-home-assistant-websocket

node-red-contrib-home-assistant-websocket

JSON →
library0.80.3jsnpmunverified

A Node-RED package that integrates Home Assistant via WebSocket and REST API, enabling automation flows within Node-RED. Version 0.80.3 requires Node-RED 3.1.1+, Node.js 18.2.0+, and Home Assistant 2024.3+. It provides dedicated nodes for triggering automations, calling services, and managing entities. This package is the de facto solution for Home Assistant automation in Node-RED, offering tighter event-driven integration compared to generic HTTP nodes.

npm install node-red-contrib-home-assistant-websocket
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-H
N
node-red-contrib-home-assistant-websocket
devopsjavascriptv0.80.3
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.

Server
Use the config node in Node-RED UI, no import needed
const Server = require('node-red-contrib-home-assistant-websocket');
This is a Node-RED module; it must be installed and nodes are added via the palette. No direct JavaScript/TypeScript import.
HA WebSocket node
Add 'ha-websocket' node from the palette in Node-RED
import { haWebSocket } from 'node-red-contrib-home-assistant-websocket';
Nodes are used within Node-RED flows, not imported programmatically.

Shows how to install and configure the package in Node-RED.

// This package is a Node-RED module, not a library for programmatic use. // To use: // 1. Install Node-RED (>=3.1.1) // 2. Run: cd ~/.node-red && npm install node-red-contrib-home-assistant-websocket // 3. Restart Node-RED // 4. Add a 'server' config node with your Home Assistant details // 5. Use 'ha-websocket' nodes in your flows
Debug
Known issues
breakingMinimum Node.js version raised to 18.2.0
fix
Update Node.js to >=18.2.0
affects: >=0.80.0
breakingMinimum Node-RED version raised to 3.1.1
fix
Update Node-RED to >=3.1.1
affects: >=0.80.0
breakingMinimum Home Assistant version raised to 2024.3
fix
Update Home Assistant to >=2024.3
affects: >=0.80.0
gotchaConfig node requires a long-lived access token generated from Home Assistant UI (Profile > Long-Lived Access Tokens) or using the add-on checkbox
fix
Generate a token from HA UI or use the add-on checkbox if running in HA add-on
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'ws'
Missing 'ws' dependency
fix
Run 'npm install ws' in the Node-RED user directory (~/.node-red)
Error: socket hang up
Incorrect token or server URL in the Home Assistant server config node
fix
Verify the access token and Home Assistant URL in the config node
TypeError: Cannot read properties of undefined (reading 'state')
Trying to access entity state before the message is fully received or the entity doesn't exist
fix
Ensure the entity_id exists and use a 'currentState' node or wait for the message payload
Upgrade
Version history
0.80.3latest on npm
Audit
Dependencies
wsrequiredWebSocket client for communication with Home Assistant
home-assistant-js-websocketrequiredTypeScript library for Home Assistant WebSocket API
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
node-red-contrib-home-assistant-websocket — npm install node-red-contrib-home-assistant-websocket · libregistry