Handle exception on projector being unavailable (#77802)

pull/77909/head
Yevhenii Vaskivskyi 2022-09-06 17:34:11 +02:00 committed by GitHub
parent d550b17bd9
commit 5459b5fdfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -3,7 +3,7 @@
"name": "Epson",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/epson",
"requirements": ["epson-projector==0.4.6"],
"requirements": ["epson-projector==0.5.0"],
"codeowners": ["@pszafer"],
"iot_class": "local_polling",
"loggers": ["epson_projector"]

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
from epson_projector import Projector
from epson_projector import Projector, ProjectorUnavailableError
from epson_projector.const import (
BACK,
BUSY,
@ -20,7 +20,6 @@ from epson_projector.const import (
POWER,
SOURCE,
SOURCE_LIST,
STATE_UNAVAILABLE as EPSON_STATE_UNAVAILABLE,
TURN_OFF,
TURN_ON,
VOL_DOWN,
@ -123,11 +122,16 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
async def async_update(self) -> None:
"""Update state of device."""
power_state = await self._projector.get_power()
_LOGGER.debug("Projector status: %s", power_state)
if not power_state or power_state == EPSON_STATE_UNAVAILABLE:
try:
power_state = await self._projector.get_power()
except ProjectorUnavailableError as ex:
_LOGGER.debug("Projector is unavailable: %s", ex)
self._attr_available = False
return
if not power_state:
self._attr_available = False
return
_LOGGER.debug("Projector status: %s", power_state)
self._attr_available = True
if power_state == EPSON_CODES[POWER]:
self._attr_state = STATE_ON

View File

@ -630,7 +630,7 @@ envoy_reader==0.20.1
ephem==4.1.2
# homeassistant.components.epson
epson-projector==0.4.6
epson-projector==0.5.0
# homeassistant.components.epsonworkforce
epsonprinter==0.0.9

View File

@ -477,7 +477,7 @@ envoy_reader==0.20.1
ephem==4.1.2
# homeassistant.components.epson
epson-projector==0.4.6
epson-projector==0.5.0
# homeassistant.components.faa_delays
faadelays==0.0.7