mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Allow get local ip to work without internet (#8855)
This commit is contained in:
parent
c49cce7243
commit
ac9c1235bb
@ -99,7 +99,10 @@ def get_local_ip():
|
|||||||
|
|
||||||
return sock.getsockname()[0]
|
return sock.getsockname()[0]
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return socket.gethostbyname(socket.gethostname())
|
try:
|
||||||
|
return socket.gethostbyname(socket.gethostname())
|
||||||
|
except socket.gaierror:
|
||||||
|
return '127.0.0.1'
|
||||||
finally:
|
finally:
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user