Remove undo_listener variable in Sony Bravia TV integration (#52033)
parent
d772488472
commit
01a26f1348
|
@ -12,14 +12,7 @@ from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PIN
|
|||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import (
|
||||
BRAVIA_COORDINATOR,
|
||||
CLIENTID_PREFIX,
|
||||
CONF_IGNORED_SOURCES,
|
||||
DOMAIN,
|
||||
NICKNAME,
|
||||
UNDO_UPDATE_LISTENER,
|
||||
)
|
||||
from .const import CLIENTID_PREFIX, CONF_IGNORED_SOURCES, DOMAIN, NICKNAME
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -35,15 +28,12 @@ async def async_setup_entry(hass, config_entry):
|
|||
ignored_sources = config_entry.options.get(CONF_IGNORED_SOURCES, [])
|
||||
|
||||
coordinator = BraviaTVCoordinator(hass, host, mac, pin, ignored_sources)
|
||||
undo_listener = config_entry.add_update_listener(update_listener)
|
||||
config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][config_entry.entry_id] = {
|
||||
BRAVIA_COORDINATOR: coordinator,
|
||||
UNDO_UPDATE_LISTENER: undo_listener,
|
||||
}
|
||||
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
||||
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
|
@ -56,8 +46,6 @@ async def async_unload_entry(hass, config_entry):
|
|||
config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ from .const import (
|
|||
ATTR_CID,
|
||||
ATTR_MAC,
|
||||
ATTR_MODEL,
|
||||
BRAVIA_COORDINATOR,
|
||||
CLIENTID_PREFIX,
|
||||
CONF_IGNORED_SOURCES,
|
||||
DOMAIN,
|
||||
|
@ -160,9 +159,7 @@ class BraviaTVOptionsFlowHandler(config_entries.OptionsFlow):
|
|||
|
||||
async def async_step_init(self, user_input=None):
|
||||
"""Manage the options."""
|
||||
coordinator = self.hass.data[DOMAIN][self.config_entry.entry_id][
|
||||
BRAVIA_COORDINATOR
|
||||
]
|
||||
coordinator = self.hass.data[DOMAIN][self.config_entry.entry_id]
|
||||
self.braviarc = coordinator.braviarc
|
||||
connected = await self.hass.async_add_executor_job(self.braviarc.is_connected)
|
||||
if not connected:
|
||||
|
|
|
@ -6,10 +6,8 @@ ATTR_MODEL = "model"
|
|||
|
||||
CONF_IGNORED_SOURCES = "ignored_sources"
|
||||
|
||||
BRAVIA_COORDINATOR = "bravia_coordinator"
|
||||
BRAVIA_CONFIG_FILE = "bravia.conf"
|
||||
CLIENTID_PREFIX = "HomeAssistant"
|
||||
DEFAULT_NAME = f"{ATTR_MANUFACTURER} Bravia TV"
|
||||
DOMAIN = "braviatv"
|
||||
NICKNAME = "Home Assistant"
|
||||
UNDO_UPDATE_LISTENER = "undo_update_listener"
|
||||
|
|
|
@ -34,13 +34,7 @@ import homeassistant.helpers.config_validation as cv
|
|||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util.json import load_json
|
||||
|
||||
from .const import (
|
||||
ATTR_MANUFACTURER,
|
||||
BRAVIA_CONFIG_FILE,
|
||||
BRAVIA_COORDINATOR,
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
)
|
||||
from .const import ATTR_MANUFACTURER, BRAVIA_CONFIG_FILE, DEFAULT_NAME, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -99,7 +93,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 Bravia TV Media Player from a config_entry."""
|
||||
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id][BRAVIA_COORDINATOR]
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
unique_id = config_entry.unique_id
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, unique_id)},
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import ATTR_MANUFACTURER, BRAVIA_COORDINATOR, DEFAULT_NAME, DOMAIN
|
||||
from .const import ATTR_MANUFACTURER, DEFAULT_NAME, DOMAIN
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Bravia TV Remote from a config entry."""
|
||||
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id][BRAVIA_COORDINATOR]
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
unique_id = config_entry.unique_id
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, unique_id)},
|
||||
|
|
Loading…
Reference in New Issue