Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Assistant WS: Send auth token upon auth request #368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kevdliu
Copy link

@kevdliu kevdliu commented Feb 26, 2024

I'm not sure when the original issue started, but at some point my home assistant logs started getting spammed with Disconnected: Did not receive auth message within 10 seconds for all three of my willow devices. Restarting home assistant and the willow devices did not resolve the issue. After looking at the home assistant WS handler and how willow communicates with home assistant over WS, my theory is that willow was sending the auth token to home assistant even before it has asked for it. Then when it does ask for the auth token, willow does not respond and the connection eventually times out.

This PR fixes this issue by having willow send the auth token only after home assistant has asked for it (by checking the type property in WS messages). After flashing this change to my willow devices, I have not seen the error since.

@nikito
Copy link
Contributor

nikito commented Feb 26, 2024

Are you using was command endpoint? That will be the default soon, and in that config willow does not talk to ha directly, it sends commands to was and was then sends commands to ha.

@kevdliu
Copy link
Author

kevdliu commented Feb 27, 2024

Are you using was command endpoint? That will be the default soon, and in that config willow does not talk to ha directly, it sends commands to was and was then sends commands to ha.

I have a bit of a weird setup that's preventing me from using the WAS command endpoint. I have my HA set up such that the response plays out of another speaker that's connected to HA (Sonos). Since I have three willow devices, I use a different auth token for each so that on the HA side, I can differentiate between the willow devices and play the response out of the correct speaker. Using the WAS command endpoint prevents me from using a different auth token for each willow device. I'm not too happy with my setup but AFAIK HA does not passthrough any sort of device identifier.

@nikito
Copy link
Contributor

nikito commented Feb 27, 2024

Are you using was command endpoint? That will be the default soon, and in that config willow does not talk to ha directly, it sends commands to was and was then sends commands to ha.

I have a bit of a weird setup that's preventing me from using the WAS command endpoint. I have my HA set up such that the response plays out of another speaker that's connected to HA (Sonos). Since I have three willow devices, I use a different auth token for each so that on the HA side, I can differentiate between the willow devices and play the response out of the correct speaker. Using the WAS command endpoint prevents me from using a different auth token for each willow device. I'm not too happy with my setup but AFAIK HA does not passthrough any sort of device identifier.

It's something we are looking into actually, HA does have a concept of this that is related to area awareness that the native satellites use. I think some other users in the experimental channel also are doing something like this, but instead have a shim between was and ha that can reroute audio. Could check in the discord and see if someone can explain what they did 🙂

@kevdliu
Copy link
Author

kevdliu commented Feb 27, 2024

Are you using was command endpoint? That will be the default soon, and in that config willow does not talk to ha directly, it sends commands to was and was then sends commands to ha.

I have a bit of a weird setup that's preventing me from using the WAS command endpoint. I have my HA set up such that the response plays out of another speaker that's connected to HA (Sonos). Since I have three willow devices, I use a different auth token for each so that on the HA side, I can differentiate between the willow devices and play the response out of the correct speaker. Using the WAS command endpoint prevents me from using a different auth token for each willow device. I'm not too happy with my setup but AFAIK HA does not passthrough any sort of device identifier.

It's something we are looking into actually, HA does have a concept of this that is related to area awareness that the native satellites use. I think some other users in the experimental channel also are doing something like this, but instead have a shim between was and ha that can reroute audio. Could check in the discord and see if someone can explain what they did 🙂

Oh that's cool! Glad to know I'm not the only one needing something like this. Could you post the link to the discord?

@nikito
Copy link
Contributor

nikito commented Feb 27, 2024

@stintel
Copy link
Collaborator

stintel commented Feb 29, 2024

As already mentioned by @nikito, command endpoint will become the default in a future release. In fact, it will become non-optional, end other endpoints will be removed from the Willow code. We documented this on https://heywillow.io/components/willow-application-server/#was-command-endpoint-mode a while ago. At that time we have decided we will not make any more changes to the Willow endpoint code. With that in mind, I am inclined to not accept this PR, but the final decision is up to @kristiankielhofner.

@kevdliu
Copy link
Author

kevdliu commented Mar 1, 2024

As already mentioned by @nikito, command endpoint will become the default in a future release. In fact, it will become non-optional, end other endpoints will be removed from the Willow code. We documented this on https://heywillow.io/components/willow-application-server/#was-command-endpoint-mode a while ago. At that time we have decided we will not make any more changes to the Willow endpoint code. With that in mind, I am inclined to not accept this PR, but the final decision is up to @kristiankielhofner.

Good to know, that's totally fair. I'm getting help on discord on how to make my setup work with WAS command endpoint. Feel free to close this pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants