mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 21:37:07 +00:00
Add available state for Epson integration (#43038)
This commit is contained in:
parent
0c9189af0a
commit
d7bcf4a3b4
@ -37,14 +37,7 @@ from homeassistant.components.media_player.const import (
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
CONF_PORT,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import entity_platform
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
@ -103,6 +96,7 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Initialize entity to control Epson projector."""
|
||||
self._name = name
|
||||
self._projector = projector
|
||||
self._available = False
|
||||
self._cmode = None
|
||||
self._source_list = list(DEFAULT_SOURCES.values())
|
||||
self._source = None
|
||||
@ -114,8 +108,10 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Update state of device."""
|
||||
power_state = await self._projector.get_property(POWER)
|
||||
_LOGGER.debug("Projector status: %s", power_state)
|
||||
if not power_state:
|
||||
if not power_state or power_state == EPSON_STATE_UNAVAILABLE:
|
||||
self._available = False
|
||||
return
|
||||
self._available = True
|
||||
if power_state == EPSON_CODES[POWER]:
|
||||
self._state = STATE_ON
|
||||
self._source_list = list(DEFAULT_SOURCES.values())
|
||||
@ -128,8 +124,6 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
self._volume = volume
|
||||
elif power_state == BUSY:
|
||||
self._state = STATE_ON
|
||||
elif power_state == EPSON_STATE_UNAVAILABLE:
|
||||
self._state = STATE_UNAVAILABLE
|
||||
else:
|
||||
self._state = STATE_OFF
|
||||
|
||||
@ -148,6 +142,11 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return if projector is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user