WebSocket missing
shenning00 opened this issue · comments
Trying out this package and am getting this -
Connection failed with code ReferenceError: WebSocket is not defined
at n (/node_modules/home-assistant-js-websocket/dist/haws.cjs.js:1:748)
With this code:
var ha = require('home-assistant-js-websocket');
function stateChanged(event) {
console.log('state changed', event);
}
ha.createConnection('ws://192.168.1.211:8123/api/websocket').then(
(conn) => {
console.log('Connection established!');
ha.subscribeEntities(conn, entities => console.log('New entities!', entities));
},
err => console.error('Connection failed with code', err)
)
This package has been developed for browsers in which WebSocket is available.
I don't know what it would take to get this working in Node.
OK - I'll take a look and let you know if I find out anything.