You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found your original code in main.py had a problem to be launched when the system is early in booting, meaning the network interface is not yet available.
Since I modified your code too much to fork a version of it, I just snap the code below.
The idea is to have a waiting stage till the network interface shows up.
"""
Get the first IP address of a network interface.
:param interface: The name of the interface.
:return: The IP address.
"""
while interface not in ni.interfaces():
print('Could not find interface %s.' % (interface,))
sleep(10)
while True:
interfacestring = ni.ifaddresses(interface)
if (2 not in interfacestring) or (len(interfacestring[2]) == 0):
print('Could not find IP of interface %s. Sleeping.' % (interface,))
sleep(10)
continue
else:
break
return interfacestring[2][0]['addr']
The text was updated successfully, but these errors were encountered:
Hi, I thank you a lot for the code you wrote.
I adapted it for my needs in my SmartThings porting to add UPNP detection of my Pi (see https://github.com/philippeportesppo/AirMentorPro2_SmartThings).
I found your original code in main.py had a problem to be launched when the system is early in booting, meaning the network interface is not yet available.
Since I modified your code too much to fork a version of it, I just snap the code below.
The idea is to have a waiting stage till the network interface shows up.
Thanks again (ou merci si vous etes en France).
def get_network_interface_ip_address(interface='wlan0'):
The text was updated successfully, but these errors were encountered: