Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
fix connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveicedgreentea committed Apr 19, 2024
1 parent 46501db commit 8f7138b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/jvc_projectors/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import itertools

from jvc_projector.jvc_projector import JVCInput, JVCProjectorCoordinator, Header
from jvc_projector.error_classes import ShouldReconnectError
from jvc_projector.error_classes import ShouldReconnectError, ConnectionClosedError
from homeassistant.helpers.event import async_track_time_interval

from .const import DOMAIN
Expand Down Expand Up @@ -365,6 +365,11 @@ async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument
await self.jvc_client.power_on()
self.stop_processing_commands.clear()
# save state
except ConnectionClosedError:
_LOGGER.error("Lost connection, reconnecting")
await self.open_conn()
# try again
await self.async_turn_on()
except Exception as err: # pylint: disable=broad-except
_LOGGER.error("Error turning on projector: %s", err)
await self.reset_everything()
Expand Down

0 comments on commit 8f7138b

Please sign in to comment.