Fix unique_id issue on onewire config entries (#50161)

This commit is contained in:
epenet
2021-05-07 14:21:03 +02:00
committed by Franck Nijhof
parent bb3ebad92f
commit 1e604fec7d
5 changed files with 5 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
except CannotConnect as 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:
# Get registries
@@ -71,5 +71,5 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
config_entry, PLATFORMS
)
if unload_ok:
hass.data[DOMAIN].pop(config_entry.unique_id)
hass.data[DOMAIN].pop(config_entry.entry_id)
return unload_ok

View File

@@ -81,7 +81,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up 1-Wire platform."""
# Only OWServer implementation works with binary sensors
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)
async_add_entities(entities, True)

View File

@@ -256,7 +256,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async def async_setup_entry(hass, config_entry, async_add_entities):
"""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(
get_entities, onewirehub, config_entry.data
)

View File

@@ -144,7 +144,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up 1-Wire platform."""
# Only OWServer implementation works with switches
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)
async_add_entities(entities, True)

View File

@@ -36,7 +36,6 @@ async def test_owserver_connect_failure(hass):
CONF_HOST: "1.2.3.4",
CONF_PORT: "1234",
},
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",
@@ -65,7 +64,6 @@ async def test_failed_owserver_listing(hass):
CONF_HOST: "1.2.3.4",
CONF_PORT: "1234",
},
unique_id=f"{CONF_TYPE_OWSERVER}:1.2.3.4:1234",
connection_class=CONN_CLASS_LOCAL_POLL,
options={},
entry_id="2",