Fix unique_id issue on onewire config entries (#50161)
parent
0c288bcabb
commit
5d5122c2a4
|
@ -23,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
except CannotConnect as exc:
|
except CannotConnect as exc:
|
||||||
raise ConfigEntryNotReady() from exc
|
raise ConfigEntryNotReady() from exc
|
||||||
|
|
||||||
hass.data[DOMAIN][config_entry.unique_id] = onewirehub
|
hass.data[DOMAIN][config_entry.entry_id] = onewirehub
|
||||||
|
|
||||||
async def cleanup_registry() -> None:
|
async def cleanup_registry() -> None:
|
||||||
# Get registries
|
# Get registries
|
||||||
|
@ -71,5 +71,5 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
config_entry, PLATFORMS
|
config_entry, PLATFORMS
|
||||||
)
|
)
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(config_entry.unique_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
|
@ -81,7 +81,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up 1-Wire platform."""
|
"""Set up 1-Wire platform."""
|
||||||
# Only OWServer implementation works with binary sensors
|
# Only OWServer implementation works with binary sensors
|
||||||
if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER:
|
if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER:
|
||||||
onewirehub = hass.data[DOMAIN][config_entry.unique_id]
|
onewirehub = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
entities = await hass.async_add_executor_job(get_entities, onewirehub)
|
entities = await hass.async_add_executor_job(get_entities, onewirehub)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
|
@ -250,7 +250,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up 1-Wire platform."""
|
"""Set up 1-Wire platform."""
|
||||||
onewirehub = hass.data[DOMAIN][config_entry.unique_id]
|
onewirehub = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = await hass.async_add_executor_job(
|
entities = await hass.async_add_executor_job(
|
||||||
get_entities, onewirehub, config_entry.data
|
get_entities, onewirehub, config_entry.data
|
||||||
)
|
)
|
||||||
|
|
|
@ -144,7 +144,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up 1-Wire platform."""
|
"""Set up 1-Wire platform."""
|
||||||
# Only OWServer implementation works with switches
|
# Only OWServer implementation works with switches
|
||||||
if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER:
|
if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER:
|
||||||
onewirehub = hass.data[DOMAIN][config_entry.unique_id]
|
onewirehub = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
entities = await hass.async_add_executor_job(get_entities, onewirehub)
|
entities = await hass.async_add_executor_job(get_entities, onewirehub)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
|
@ -35,7 +35,6 @@ async def test_owserver_connect_failure(hass):
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
CONF_PORT: "1234",
|
CONF_PORT: "1234",
|
||||||
},
|
},
|
||||||
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
|
|
||||||
options={},
|
options={},
|
||||||
entry_id="2",
|
entry_id="2",
|
||||||
)
|
)
|
||||||
|
@ -63,7 +62,6 @@ async def test_failed_owserver_listing(hass):
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
CONF_PORT: "1234",
|
CONF_PORT: "1234",
|
||||||
},
|
},
|
||||||
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
|
|
||||||
options={},
|
options={},
|
||||||
entry_id="2",
|
entry_id="2",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue