Skip to content

Commit

Permalink
Fix unique_id issue on onewire config entries (home-assistant#50161)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored May 7, 2021
1 parent 0c288bc commit 5d5122c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/onewire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion homeassistant/components/onewire/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onewire/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""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
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onewire/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tests/components/onewire/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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",
options={},
entry_id="2",
)
Expand Down Expand Up @@ -63,7 +62,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",
options={},
entry_id="2",
)
Expand Down

0 comments on commit 5d5122c

Please sign in to comment.