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

Change voice assistant to use fixed ports #107406

Closed
wants to merge 6 commits into from

Conversation

fiatguy85
Copy link

@fiatguy85 fiatguy85 commented Jan 6, 2024

Proposed change

Change voice assistant to use a fixed port, rather than a random one. This way, only a fixed port needs to be opened for a device streaming to the voice assistant, rather than the whole range of UDP Ports.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fiatguy85

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

home-assistant bot commented Jan 6, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

home-assistant bot commented Jan 6, 2024

Hey there @OttoWinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@kbx81
Copy link
Contributor

kbx81 commented Jan 7, 2024

IIRC, the reason this wasn't done was because, if multiple VAs happen to be working at the same time, they all break...

@fiatguy85
Copy link
Author

I see, that does make sense. To limit the port to a range of ports, you would need to generate a random number within a range and potentially ensure it was not one of the last one or the last few assigned?

@WebSpider
Copy link
Contributor

Is the change to .gitignore intentional?

@fiatguy85
Copy link
Author

Is the change to .gitignore intentional?

No, that was a mistake, I was trying to ensure nothing from my copied config directory got pulled in.

@fiatguy85
Copy link
Author

Ok, I have now updated this to use a small range of random ports, which avoids the conflict of multiple VAs working at the same time, but allows the user to only open a set number of ports.

@fiatguy85 fiatguy85 marked this pull request as ready for review January 17, 2024 06:04
@fiatguy85
Copy link
Author

This should fix #105106

@fiatguy85 fiatguy85 changed the title Change voice assistant to use fixed port Change voice assistant to use fixed ports Jan 17, 2024
@home-assistant home-assistant bot marked this pull request as draft February 27, 2024 03:21
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
@sistason
Copy link

sistason commented Mar 4, 2024

Unsure if relevant or not: I am using this PR and it works.

I cloned this fork, build the image and forwarded 10500-10520/udp into the container without network_mode: host.
With that, I can successfully use my M5 Atom for Voice Control, the previous random udp packets I saw in tcpdump are now in that range so the docker port-forwarding can do its job.

@Someguitarist
Copy link

Adding that using this PR fixes my problem. I'm actually using the HA container with network_mode=host, and still can't receive the random UDP ports without disabling UFW.

@jesserockz
Copy link
Member

I am going to close this as we are currently working to send and receive the audio via the ESPHome API to make UDP not required.

@jesserockz jesserockz closed this Mar 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants