mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Replace util.get_local_ip in favor of components.network.async_get_source_ip() - part 3 (#53424)
This commit is contained in:
parent
f3bf0fdb09
commit
5a6be2370b
@ -1,7 +1,9 @@
|
||||
"""Support for Roku API emulation."""
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, util
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.network import async_get_source_ip
|
||||
from homeassistant.components.network.const import PUBLIC_TARGET_IP
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
@ -71,7 +73,9 @@ async def async_setup_entry(hass, config_entry):
|
||||
|
||||
name = config[CONF_NAME]
|
||||
listen_port = config[CONF_LISTEN_PORT]
|
||||
host_ip = config.get(CONF_HOST_IP) or util.get_local_ip()
|
||||
host_ip = config.get(CONF_HOST_IP) or await async_get_source_ip(
|
||||
hass, PUBLIC_TARGET_IP
|
||||
)
|
||||
advertise_ip = config.get(CONF_ADVERTISE_IP)
|
||||
advertise_port = config.get(CONF_ADVERTISE_PORT)
|
||||
upnp_bind_multicast = config.get(CONF_UPNP_BIND_MULTICAST)
|
||||
|
@ -4,6 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/emulated_roku",
|
||||
"requirements": ["emulated_roku==0.2.1"],
|
||||
"dependencies": ["network"],
|
||||
"codeowners": [],
|
||||
"iot_class": "local_push"
|
||||
}
|
||||
|
@ -93,7 +93,11 @@ async def test_setup_entry_successful(hass):
|
||||
async def test_unload_entry(hass):
|
||||
"""Test being able to unload an entry."""
|
||||
entry = Mock()
|
||||
entry.data = {"name": "Emulated Roku Test", "listen_port": 8060}
|
||||
entry.data = {
|
||||
"name": "Emulated Roku Test",
|
||||
"listen_port": 8060,
|
||||
emulated_roku.CONF_HOST_IP: "1.2.3.5",
|
||||
}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.emulated_roku.binding.EmulatedRokuServer",
|
||||
|
Loading…
x
Reference in New Issue
Block a user