Fix Kodi on/off status (#117436)

* Fix Kodi Issue 104603

Fixes issue, that Kodi media player is displayed as online even when offline. The issue occurrs when using HTTP(S) only (no web Socket) integration after kodi was found online once.
Issue: In async_update the connection exceptions from self._kodi.get_players are not catched and therefore self._players (and the like) are not reset. The call of self._connection.connected returns always true for HTTP(S) connections.

Solution: Catch Exceptions from self._kodi.get_players und reset state in case of HTTP(S) only connection. Otherwise keep current behaviour.

* Fix Kodi Issue 104603 / code style adjustments

as requested
pull/117588/head
mk-81 2024-05-14 21:02:17 +02:00 committed by GitHub
parent 641754e0bb
commit 0df9006bf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -480,7 +480,13 @@ class KodiEntity(MediaPlayerEntity):
self._reset_state()
return
self._players = await self._kodi.get_players()
try:
self._players = await self._kodi.get_players()
except (TransportError, ProtocolError):
if not self._connection.can_subscribe:
self._reset_state()
return
raise
if self._kodi_is_off:
self._reset_state()