Skip to content

Add IPv6 to WifiInfoSensor #4198

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

Closed
h3mmy opened this issue Feb 10, 2024 · 4 comments · Fixed by #4202
Closed

Add IPv6 to WifiInfoSensor #4198

h3mmy opened this issue Feb 10, 2024 · 4 comments · Fixed by #4202
Labels
enhancement New feature or request sensor-tracking

Comments

@h3mmy
Copy link
Contributor

h3mmy commented Feb 10, 2024

Is your feature request related to a problem? Please describe.

My core personal issue is that my phone regularly drops it's IPv6 address. This drives me nuts. I want to be able to detect when this happens and automatically cycle the wifi to regain an IPv6 assignment. I thought, well Home Assistant should have access to this data and is always running on my phone anyway. After checking the sensor for WifiInfo wifi_ip_address, I noted it was only the IPv4 address. This struck me as odd. I went to check the code in case there was a hidden option that I maybe missed.

This was not the case. It turns out that the companion app only retrieves the IPv4 address and additionally relies on a deprecated (as of version 31) way to get the address.

https://github.com/home-assistant/android/blob/master/common/src/main/java/io/homeassistant/companion/android/common/sensors/NetworkSensorManager.kt#L345

Describe the solution you'd like

Update the NetworkSensorManager to use LinkAddress to retrieve the inet addresses and display both types of addresses as part of the wifiInfo sensor. I am happy to open a PR for this change as well.

Describe alternatives you've considered, if any

Doing it manually instead of using home-assistant. I feel like the simple check and cycle is exactly the kind of automation that fits the goals of the home-assistant project.

Additional context

I am happy to make the code changes, which should be rather minimal. Just want a go ahead from someone before putting in the work.

@h3mmy h3mmy added the enhancement New feature or request label Feb 10, 2024
@dshokouhi
Copy link
Member

The current sensor is designed to show the IPv4 address. If you would like to add one for IPv6 please make sure its a new sensor 😃 . The other sensor needs to continue to use the deprecated method to support older devices but a new sensor can be setup to show the IPv6 address as its state.

@h3mmy
Copy link
Contributor Author

h3mmy commented Feb 10, 2024

That seems reasonable to me. It'll probably take me a little extra fiddling to get it right, but I can get working on that then. Thanks for the quick response!

@h3mmy
Copy link
Contributor Author

h3mmy commented Feb 13, 2024

This might be a silly question, but is there somewhere specific I can add unit tests to? I'm not able to find the testcase files in the repository.

@jpelgrom
Copy link
Member

This might be a silly question, but is there somewhere specific I can add unit tests to? I'm not able to find the testcase files in the repository.

There are currently no unit tests in the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sensor-tracking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants