Skip to content

Commit

Permalink
Fix Kodi on/off status (#117436)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mk-81 committed May 14, 2024
1 parent 641754e commit 0df9006
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion homeassistant/components/kodi/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,13 @@ async def async_update(self) -> None:
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()
Expand Down

0 comments on commit 0df9006

Please sign in to comment.