8000 Use entry.async_on_unload in monoprice by epenet · Pull Request #148016 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use entry.async_on_unload in monoprice #148016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions homeassistant/components/monoprice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .const import (
CONF_NOT_FIRST_RUN,
DOMAIN,
FIRST_RUN,
MONOPRICE_OBJECT,
UNDO_UPDATE_LISTENER,
)
from .const import CONF_NOT_FIRST_RUN, DOMAIN, FIRST_RUN, MONOPRICE_OBJECT

PLATFORMS = [Platform.MEDIA_PLAYER]

Expand All @@ -41,11 +35,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry, data={**entry.data, CONF_NOT_FIRST_RUN: True}
)

undo_listener = entry.add_update_listener(_update_listener)
entry.async_on_unload(entry.add_update_listener(_update_listener))

hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
MONOPRICE_OBJECT: monoprice,
UNDO_UPDATE_LISTENER: undo_listener,
FIRST_RUN: first_run,
}

Expand All @@ -60,8 +53,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not unload_ok:
return False

hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()

def _cleanup(monoprice) -> None:
"""Destroy the Monoprice object.

Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/monoprice/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@

FIRST_RUN = "first_run"
MONOPRICE_OBJECT = "monoprice_object"
UNDO_UPDATE_LISTENER = "update_update_listener"
0