Make dispatch signals unique per server (#28029)
This commit is contained in:
parent
6844d203a1
commit
d1fcc5762b
4 changed files with 18 additions and 6 deletions
|
@ -17,9 +17,9 @@ PLEX_CONFIG_FILE = "plex.conf"
|
|||
PLEX_MEDIA_PLAYER_OPTIONS = "plex_mp_options"
|
||||
PLEX_SERVER_CONFIG = "server_config"
|
||||
|
||||
PLEX_NEW_MP_SIGNAL = "plex_new_mp_signal"
|
||||
PLEX_NEW_MP_SIGNAL = "plex_new_mp_signal.{}"
|
||||
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL = "plex_update_mp_signal.{}"
|
||||
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal"
|
||||
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal.{}"
|
||||
|
||||
CONF_SERVER = "server"
|
||||
CONF_SERVER_IDENTIFIER = "server_id"
|
||||
|
|
|
@ -62,7 +62,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
hass, config_entry, async_add_entities, server_id, new_entities
|
||||
)
|
||||
|
||||
unsub = async_dispatcher_connect(hass, PLEX_NEW_MP_SIGNAL, async_new_media_players)
|
||||
unsub = async_dispatcher_connect(
|
||||
hass, PLEX_NEW_MP_SIGNAL.format(server_id), async_new_media_players
|
||||
)
|
||||
hass.data[PLEX_DOMAIN][DISPATCHERS][server_id].append(unsub)
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@ class PlexSensor(Entity):
|
|||
"""Run when about to be added to hass."""
|
||||
server_id = self._server.machine_identifier
|
||||
unsub = async_dispatcher_connect(
|
||||
self.hass, PLEX_UPDATE_SENSOR_SIGNAL, self.async_refresh_sensor
|
||||
self.hass,
|
||||
PLEX_UPDATE_SENSOR_SIGNAL.format(server_id),
|
||||
self.async_refresh_sensor,
|
||||
)
|
||||
self.hass.data[PLEX_DOMAIN][DISPATCHERS][server_id].append(unsub)
|
||||
|
||||
|
|
|
@ -147,9 +147,17 @@ class PlexServer:
|
|||
self.refresh_entity(client_id, None, None)
|
||||
|
||||
if new_entity_configs:
|
||||
dispatcher_send(self._hass, PLEX_NEW_MP_SIGNAL, new_entity_configs)
|
||||
dispatcher_send(
|
||||
self._hass,
|
||||
PLEX_NEW_MP_SIGNAL.format(self.machine_identifier),
|
||||
new_entity_configs,
|
||||
)
|
||||
|
||||
dispatcher_send(self._hass, PLEX_UPDATE_SENSOR_SIGNAL, sessions)
|
||||
dispatcher_send(
|
||||
self._hass,
|
||||
PLEX_UPDATE_SENSOR_SIGNAL.format(self.machine_identifier),
|
||||
sessions,
|
||||
)
|
||||
|
||||
@property
|
||||
def friendly_name(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue