diff --git a/homeassistant/components/plex/sensor.py b/homeassistant/components/plex/sensor.py index 21e8e1a8a58..f4d5d24049c 100644 --- a/homeassistant/components/plex/sensor.py +++ b/homeassistant/components/plex/sensor.py @@ -2,7 +2,10 @@ import logging from homeassistant.core import callback -from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send +from homeassistant.helpers.dispatcher import ( + async_dispatcher_connect, + async_dispatcher_send, +) from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_call_later @@ -58,7 +61,7 @@ class PlexSensor(Entity): @callback def update_plex(_): - dispatcher_send( + async_dispatcher_send( self.hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(self._server.machine_identifier), ) diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py index a7b66c3a3ba..4134ad4e32b 100644 --- a/homeassistant/components/plex/server.py +++ b/homeassistant/components/plex/server.py @@ -12,7 +12,8 @@ import requests.exceptions from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL -from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_send +from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_call_later from .const import ( @@ -175,11 +176,12 @@ class PlexServer: if config_entry_update_needed: raise ShouldUpdateConfigEntry - def refresh_entity(self, machine_identifier, device, session): + @callback + def async_refresh_entity(self, machine_identifier, device, session): """Forward refresh dispatch to media_player.""" unique_id = f"{self.machine_identifier}:{machine_identifier}" _LOGGER.debug("Refreshing %s", unique_id) - dispatcher_send( + async_dispatcher_send( self.hass, PLEX_UPDATE_MEDIA_PLAYER_SIGNAL.format(unique_id), device, @@ -262,7 +264,7 @@ class PlexServer: if client_id in new_clients: new_entity_configs.append(client_data) else: - self.refresh_entity( + self.async_refresh_entity( client_id, client_data["device"], client_data.get("session") ) @@ -272,7 +274,7 @@ class PlexServer: self._known_clients - self._known_idle - ignored_clients ).difference(available_clients) for client_id in idle_clients: - self.refresh_entity(client_id, None, None) + self.async_refresh_entity(client_id, None, None) self._known_idle.add(client_id) if new_entity_configs: