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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ omit =
homeassistant/components/pjlink/media_player.py
homeassistant/components/plaato/*
homeassistant/components/plex/media_player.py
homeassistant/components/plex/models.py
homeassistant/components/plex/sensor.py
homeassistant/components/plum_lightpad/light.py
homeassistant/components/pocketcasts/sensor.py
Expand Down
11 changes: 4 additions & 7 deletions homeassistant/components/plex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Support to embed Plex."""
import asyncio
import functools
from functools import partial
import logging

Expand Down Expand Up @@ -35,10 +34,7 @@
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from .const import (
CONF_SERVER,
Expand Down Expand Up @@ -176,6 +172,7 @@ def plex_websocket_callback(signal, data, error):

if data == STATE_CONNECTED:
_LOGGER.debug("Websocket to %s successful", entry.data[CONF_SERVER])
hass.async_create_task(async_update_plex())
elif data == STATE_DISCONNECTED:
_LOGGER.debug(
"Websocket to %s disconnected, retrying", entry.data[CONF_SERVER]
Expand All @@ -190,7 +187,7 @@ def plex_websocket_callback(signal, data, error):
hass.async_create_task(hass.config_entries.async_reload(entry.entry_id))

elif signal == SIGNAL_DATA:
async_dispatcher_send(hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id))
hass.async_create_task(plex_server.async_update_session(data))

session = async_get_clientsession(hass)
verify_ssl = server_config.get(CONF_VERIFY_SSL)
Expand Down Expand Up @@ -219,7 +216,7 @@ def close_websocket_session(_):
task = hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
)
task.add_done_callback(functools.partial(start_websocket_session, platform))
task.add_done_callback(partial(start_websocket_session, platform))

async def async_play_on_sonos_service(service_call):
await hass.async_add_executor_job(play_on_sonos, hass, service_call)
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/plex/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
PLEX_SERVER_CONFIG = "server_config"

PLEX_NEW_MP_SIGNAL = "plex_new_mp_signal.{}"
PLEX_UPDATE_MEDIA_PLAYER_SESSION_SIGNAL = "plex_update_session_signal.{}"
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL = "plex_update_mp_signal.{}"
PLEX_UPDATE_PLATFORMS_SIGNAL = "plex_update_platforms_signal.{}"
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal.{}"
Expand Down
Loading