Skip to content
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
7 changes: 5 additions & 2 deletions homeassistant/components/plex/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -58,7 +61,7 @@ async def async_refresh_sensor(self, sessions):

@callback
def update_plex(_):
dispatcher_send(
async_dispatcher_send(
self.hass,
PLEX_UPDATE_PLATFORMS_SIGNAL.format(self._server.machine_identifier),
)
Expand Down
12 changes: 7 additions & 5 deletions homeassistant/components/plex/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

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 (
Expand Down Expand Up @@ -175,11 +176,12 @@ def _update_plexdirect_hostname():
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."""
Comment thread
jjlawren marked this conversation as resolved.
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,
Expand Down Expand Up @@ -262,7 +264,7 @@ async def async_update_platforms(self):
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")
)

Expand All @@ -272,7 +274,7 @@ async def async_update_platforms(self):
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:
Expand Down