home-assistant / home-assistant-js-websocket

:aerial_tramway: JavaScript websocket client for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subscribeMessage resubscribing being sent before custom integration endpoint is loaded

zachowj opened this issue · comments

commented

I am using subscribeMessage to hit an endpoint that's created from a custom integration. Now that HA allows connections before all integrations are loaded I am running into the issue where the resubscribing of these endpoints, after a reboot of HA, is being sent before the integration has been loaded. This is causing the subscription message to be lost and an Unhandled promise rejection to be thrown.

Is allowing subscribeMessage to accept an additional parameter to disable resubscription a viable solution or is there another option I am missing? Am I at the point of needing to roll my own HA WebSocket client?

Ah, unexpected side effect 🙂

I wonder if we can either built-in an error handling logic that can wait till the system is started or that we should just built that exact logic in.

commented

In my case leaving it up to the user to resend the message allows me to registered entities with HA as soon as the integration is loaded and not have to wait for HA to be in a running state. This might not be ideal in all use cases. Either option would resolve this issue.