Skip to content

Add multiple NICs in govee_light_local#128123

Merged
emontnemery merged 2 commits intohome-assistant:devfrom
itewk:feature/govee-multi-nic
Aug 28, 2025
Merged

Add multiple NICs in govee_light_local#128123
emontnemery merged 2 commits intohome-assistant:devfrom
itewk:feature/govee-multi-nic

Conversation

@itewk
Copy link
Contributor

@itewk itewk commented Oct 10, 2024

Proposed change

Currently govee_light_local can only discover and control devices on the primary NIC.
This adds support for discovering and controlling devices on any NIC with an IPv4 address.

This is built upon @mill1000 work in dev...mill1000:core:issue/govee_discovery

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:

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

To help with the load of incoming pull requests:

@home-assistant
Copy link

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

Code owner commands

Code owners of govee_light_local 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 govee_light_local 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.

@itewk itewk force-pushed the feature/govee-multi-nic branch 2 times, most recently from 3dd8d67 to dda17e3 Compare October 10, 2024 20:15
@itewk itewk marked this pull request as draft October 10, 2024 20:16
@itewk itewk force-pushed the feature/govee-multi-nic branch 2 times, most recently from fe63b99 to ad216d8 Compare October 10, 2024 20:29
from homeassistant.core import HomeAssistant


async def _async_get_all_source_ipv4_ips(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should re-invent the wheel here. The Network integration has async_get_enabled_source_ips which can easily be filtered down to IPv4 addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mill1000 the problem with async_get_enabled_source_ips is that it doesnt actually get all the IPs. There is some logic that decideds which NICs are enabled or not based on like mDNS hops or something. at least for me it was calculating my secondary nic as disabled. so i had to write a function that didn't filter out "disabled" devices.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. Is your secondary NIC configured via System > Network?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it shows up in system network in the UI if that is what you are asking.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm.. that's quite a bit different looking than mine. Must be a HAOS vs container thing.

Here's mine where I manually enable a 2nd adapter. But I'm broadly assuming this is what "enables" another interface.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

im running on supervised installer. i was looking for a UI like that....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to make sure i wasn't crazy i tested using the async_get_enabled_source_ips and it doesn't return the IP for my secondary NIC.

so idk if this is just a me problem, and i dont know how else i could work around it, or if some other problem.

@itewk itewk force-pushed the feature/govee-multi-nic branch 8 times, most recently from 5731ea1 to 0e00b4b Compare October 10, 2024 21:20
@itewk
Copy link
Contributor Author

itewk commented Oct 10, 2024

i have no idea what i would add for new tests here

@itewk itewk marked this pull request as ready for review October 10, 2024 21:26
@MartinHjelmare MartinHjelmare changed the title govee_light_local - add support for multiple NICs Add multiple NICs in govee_light_local Oct 15, 2024
if adapter["ipv4"]:
addrs_ipv4 = [IPv4Address(ipv4["address"]) for ipv4 in adapter["ipv4"]]
sources.extend(addrs_ipv4)
if adapter["ipv6"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove the if and the continue since it's the last instruction in the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am happy to make that change but based on the previous threads it would seem not ideal for this PR to include the custom function for getting all IPv4 addresses that works around what seems to be an issue only for me that my additional NIC showes up as deactivated when using the stalk get enabled IPv4 addresses function.

so i was thinking i should re-do this PR without the custom function and ill leave the custom work around on my own version.

i was thinking maybe doing another PR that exposes a configuration option for listing the IPs want to listen on.

thoughts? should I leave this fucntion in here, or update to use the stalk get enabled IPs function?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't rip out this code just on my behalf. It'd be great if a dev more familiar with the networking code could comment.

@bryanyork
Copy link
Contributor

Prob not in scope, but can we extend this PR to support other network ranges? I have multiple networks via VLAN's and this integration doesn't work for me. In my case I have another subnet I would like to access, and not multiple network interfaces.

@moutonnoireu
Copy link

Anyone to merge this ? The Govee integration is not working for a lot of folks.

@itewk
Copy link
Contributor Author

itewk commented Jan 27, 2025

i think it was on me to break up the two parts of this. ill try and do that this week.

@felixschndr
Copy link
Contributor

@itewk Any news on this? Thank you for your work! :)

@moutonnoireu
Copy link

Any news @itewk ? Still waiting for this :)

@itewk
Copy link
Contributor Author

itewk commented Apr 9, 2025

:( i know. im sorry. life.

this code is still working as is in my home. i guess @mill1000 and @Galorhallen what do you need to see to want to merge this in?

@emontnemery
Copy link
Contributor

emontnemery commented Aug 26, 2025

@itewk based on the test done by @jhollowe, do you think it's OK to merge the PR now, or do you need also a test with the modification suggested here: #128123 (comment)

Also, did you find the settings under /config/network? Can you enable the required NICs there yourself?

To find it via the UI, first click settings:
image

Then system:
image

And finally network:
image

Where you have the setting (note that the text is now improved compared to my previous screenshot):
image

@itewk
Copy link
Contributor Author

itewk commented Aug 26, 2025

@itewk based on the test done by @jhollowe, do you think it's OK to merge the PR now, or do you need also a test with the modification suggested here: #128123 (comment)

Yes. but i need to remove the use of the custom function that bypasses disabled NICS because of my own issue. Trying to do that now.

Also, did you find the settings under /config/network? Can you enable the required NICs there yourself?

My network settings look different, see: #128123 (comment)

@itewk itewk force-pushed the feature/govee-multi-nic branch 4 times, most recently from cd8c611 to c5fa7f0 Compare August 26, 2025 16:48
@itewk
Copy link
Contributor Author

itewk commented Aug 26, 2025

@jhollowe i removed my personal workaround for my NIC problem. would you mind testing again?

@itewk itewk force-pushed the feature/govee-multi-nic branch 3 times, most recently from d211609 to 2867bb8 Compare August 26, 2025 19:11
@itewk
Copy link
Contributor Author

itewk commented Aug 26, 2025

rebased.

@emontnemery
Copy link
Contributor

My network settings look different, see: #128123 (comment)

That screenshot is almost a year old though, does it still look the same?

@itewk
Copy link
Contributor Author

itewk commented Aug 27, 2025

My network settings look different, see: #128123 (comment)

That screenshot is almost a year old though, does it still look the same?

it looks the same. but now i have a warning that my install type is being depreciated. so i am going to have to change install types. sigh

@emontnemery
Copy link
Contributor

@itewk your screenshot is of the first panel in the network settings, which allows configuring IP address etc.
If you scroll down, you should see the panel in my screenshot.

You may need to enable "advanced mode" in user settings.

@itewk
Copy link
Contributor Author

itewk commented Aug 27, 2025

@itewk your screenshot is of the first panel in the network settings, which allows configuring IP address etc. If you scroll down, you should see the panel in my screenshot.

You may need to enable "advanced mode" in user settings.

ooop. i see it. but it only lists one of my interfaces, it doesn't list both. so I don't know whats up with that. when i use my little cheat work around in code it definitely finds both, just one is listed as disabled.

@itewk
Copy link
Contributor Author

itewk commented Aug 27, 2025

@itewk your screenshot is of the first panel in the network settings, which allows configuring IP address etc. If you scroll down, you should see the panel in my screenshot.
You may need to enable "advanced mode" in user settings.

ooop. i see it. but it only lists one of my interfaces, it doesn't list both. so I don't know whats up with that. when i use my little cheat work around in code it definitely finds both, just one is listed as disabled.

nevermind! OMG! i had to uncheck autoconfigure and then both interfaces listed and then i was able to enable both! testing now!!!!

Currently govee_light_local can only discover and control devices on the
primary NIC.
This adds support for discovering and controlling devices on any NIC
with an IPv4 address.
@itewk itewk force-pushed the feature/govee-multi-nic branch from fc02277 to 097c3fc Compare August 27, 2025 16:45
@itewk
Copy link
Contributor Author

itewk commented Aug 27, 2025

fixed issue where it was trying to listen on IPv6 addresses.

I have tested trhis locally and it is all working for me with no weird hacks. thanks @emontnemery

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @itewk 👍

@emontnemery emontnemery merged commit f4673f4 into home-assistant:dev Aug 28, 2025
34 checks passed
@itewk
Copy link
Contributor Author

itewk commented Aug 28, 2025

Wahooooo! Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2025
@abmantis
Copy link
Member

abmantis commented Sep 1, 2025

It seems that this change broke the integration. Fixes:

#151540
#151541

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.

Govee light local doesn't use all available network interfaces in discovery