A word about HA -> HE integration

Unfortunately it’s not opening. You can see the time of the screenshot at the top left is 11:47pm and the websocket closed at 11:33pm

When you say you restarted the HA service do you mean restart HA? I did that and my system reconnected immediately.

I do it this way. Only restarting the HA service, not the virtual machine.

I did it this way. Which should be the same.

Screenshot_20210216_122903

You are right... with your way it does not reconnect.

Edit: My mistake I turn on logging after the disconnection. It does not reconnect with the other way also.

1 Like

Ah OK. Was just about to respond that after 15 min using your posted method, I also don't get a reconnect.

This isn't a big deal if it's only happening when the HA service is restarted. As long as it's known you have to manually re-initialize the websocket in that situation, I personally think it's fine.

However, if there was status in the driver window whether the websocket is open or closed, that would be helpful, instead of having to look at the log.

I think the point of having the automatic reconnect was exactly to handle a case like this one. I suspect shutting down HA completely and restarting it will result in a failure to reconnect also.

1 Like

Strange... If I restart using the following method, everything reconnects fine...

reconnection...

The build you are using is v0.1.18 ?

Yes.

We could add a step to do this periodically and then execute the reconnect logic if it fails.

The API supports receiving a ping from the client and returning a pong. This serves as a heartbeat to ensure the connection is still alive:

{
    "id": 19,
    "type": "ping"
}
The server must send a pong back as quickly as possible, if the connection is still active:

{
    "id": 19,
    "type": "pong"
}

That is exactly what I did and it does not reconnect. Strangely I never get those failure warning like yours in my logs

Maybe this is an anomaly that occurs when using Virtual Box or Docker? @ogiewon You are running yours on a RPi correct?

@SmartHomePrimer, when it is failing to reconnect, do you see the reconnection method scheduled on your device page in HE?

I believe this is done automagically behind the scenes via the Hubitat webSocket API... I know I have seen ping/pong messages appear in my log from my Harmonu hub driver....

No
Screen Shot 2021-02-16 at 1.09.40 PM

There's a ws protocol level ping/pong that HE handles automatically behind the scenes. This is a user/message level API with HA that we could also add. I was thinking that it could be a fail-safe if the websocketStatus errors were missed or not as expected.

1 Like

Is this even after you refresh the device page?

1 Like

Yes

Let me take a step back and try this with a new HA import device on another hub that has no other websockets open. This is all on my main hub and it has other connections open that maybe is a factor.

I just stop my HA and nothing is scheduled in my device page