-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Add function to check internal network availability #117483
base: dev
Are you sure you want to change the base?
Conversation
Added a new function `is_internal_network_available` to determine if the Home Assistant instance has access to the internal network. This function attempts to connect to a specified router IP address and port to verify network availability. Useful for enabling or disabling features based on internal network connectivity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
||
|
||
@bind_hass | ||
def is_internal_network_available(hass: HomeAssistant) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is using this?
"""Check if the Home Assistant instance has access to the internal network.""" | ||
# Check the availability of the router's network interface | ||
router_ip = "192.168.1.1" # IP address of the router in your network | ||
router_port = 80 # Port for accessing the router's web interface (e.g., 80 for HTTP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes an assumption the router has a web interface (hint: mine has not...)
Added a new function
is_internal_network_available
to determine if the Home Assistant instance has access to the internal network. This function attempts to connect to a specified router IP address and port to verify network availability. Useful for enabling or disabling features based on internal network connectivity.Breaking change
Proposed change
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: