@@ -207,36 +207,37 @@ async def _async_update_platforms(self):
207207 )
208208 return
209209
210- for device in devices :
210+ def process_device ( source , device ) :
211211 self ._known_idle .discard (device .machineIdentifier )
212- available_clients [ device .machineIdentifier ] = {"device" : device }
212+ available_clients . setdefault ( device .machineIdentifier , {"device" : device })
213213
214214 if device .machineIdentifier not in self ._known_clients :
215215 new_clients .add (device .machineIdentifier )
216- _LOGGER .debug ("New device: %s" , device .machineIdentifier )
216+ _LOGGER .debug (
217+ "New %s %s: %s" , device .product , source , device .machineIdentifier
218+ )
219+
220+ for device in devices :
221+ process_device ("device" , device )
217222
218223 for session in sessions :
219224 if session .TYPE == "photo" :
220225 _LOGGER .debug ("Photo session detected, skipping: %s" , session )
221226 continue
227+
222228 session_username = session .usernames [0 ]
223229 for player in session .players :
224230 if session_username and session_username not in monitored_users :
225231 ignored_clients .add (player .machineIdentifier )
226232 _LOGGER .debug (
227- "Ignoring Plex client owned by '%s'" , session_username
233+ "Ignoring %s client owned by '%s'" ,
234+ player .product ,
235+ session_username ,
228236 )
229237 continue
230- self ._known_idle .discard (player .machineIdentifier )
231- available_clients .setdefault (
232- player .machineIdentifier , {"device" : player }
233- )
238+ process_device ("session" , player )
234239 available_clients [player .machineIdentifier ]["session" ] = session
235240
236- if player .machineIdentifier not in self ._known_clients :
237- new_clients .add (player .machineIdentifier )
238- _LOGGER .debug ("New session: %s" , player .machineIdentifier )
239-
240241 new_entity_configs = []
241242 for client_id , client_data in available_clients .items ():
242243 if client_id in ignored_clients :
0 commit comments