home-assistant / home-assistant-js-websocket

:aerial_tramway: JavaScript websocket client for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connection class doesn't resubscribe to events if event_type empty

zachowj opened this issue · comments

commented

Not sure if this is intended but if you subscribe to subscribe_events with an empty event_type the connection class won't resubscribe to subscribe_events on a reconnect to the websocket.

if (oldSocket) {
const oldCommands = this.commands;
// reset to original state
this.commandId = 1;
this.commands = {};
Object.keys(oldCommands).forEach(id => {
const info = oldCommands[id];
if (info.eventType) {
this.subscribeEvents(info.eventCallback, info.eventType).then(
unsub => {
info.unsubscribe = unsub;
}
);
}
});
this.fireEvent("ready");
}
}

Yeah that is weird 🤔

Could you share what you're building?

commented

I have forked node-red-contrib-home-assistant and have converted it to start using websocket and the new auth system, well once you guys release the long-lived access token (home-assistant/core#16453).

Hopefully plan on having something pushed to the public in short order. It's my first real big open source project and pretty sure that I am trying to make it to prefect before releasing it.

That's awesome!