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

Use hass.add_job in samsungtv #66976

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 3 commits into from
Feb 21, 2022
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
4 changes: 2 additions & 2 deletions homeassistant/components/samsungtv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.async_ import run_callback_threadsafe

from .bridge import (
SamsungTVBridge,
Expand Down Expand Up @@ -119,6 +118,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
bridge = await _async_create_bridge_with_updated_data(hass, entry)

# Ensure new token gets saved against the config_entry
@callback
def _update_token() -> None:
"""Update config entry with the new token."""
hass.config_entries.async_update_entry(
Expand All @@ -127,7 +127,7 @@ def _update_token() -> None:

def new_token_callback() -> None:
"""Update config entry with the new token."""
run_callback_threadsafe(hass.loop, _update_token)
hass.add_job(_update_token)

bridge.register_new_token_callback(new_token_callback)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/samsungtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def update(self) -> None:

if self._attr_state == STATE_ON and self._app_list is None:
self._app_list = {} # Ensure that we don't update it twice in parallel
self.hass.async_add_job(self._update_app_list)
self._update_app_list()

def _update_app_list(self) -> None:
self._app_list = self._bridge.get_app_list()
Expand Down
0