Address review feedback for Epson (#43012)
* Martin review * Update homeassistant/components/epson/__init__.py Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> * fix STATE_UNAVAILABLE Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
parent
537c0c41eb
commit
3d4c530dd0
5 changed files with 9 additions and 11 deletions
homeassistant/components/epson
|
@ -3,11 +3,11 @@ import asyncio
|
|||
import logging
|
||||
|
||||
from epson_projector import Projector
|
||||
from epson_projector.const import POWER
|
||||
from epson_projector.const import POWER, STATE_UNAVAILABLE as EPSON_STATE_UNAVAILABLE
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_PLATFORM
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
|
@ -27,7 +27,7 @@ async def validate_projector(hass: HomeAssistant, host, port):
|
|||
port=port,
|
||||
)
|
||||
_power = await epson_proj.get_property(POWER)
|
||||
if not _power or _power == STATE_UNAVAILABLE:
|
||||
if not _power or _power == EPSON_STATE_UNAVAILABLE:
|
||||
raise CannotConnect
|
||||
return epson_proj
|
||||
|
||||
|
|
|
@ -35,11 +35,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await validate_projector(
|
||||
self.hass, user_input[CONF_HOST], user_input[CONF_PORT]
|
||||
)
|
||||
except CannotConnect:
|
||||
errors["base"] = "cannot_connect"
|
||||
else:
|
||||
return self.async_create_entry(
|
||||
title=user_input.pop(CONF_NAME), data=user_input
|
||||
)
|
||||
except CannotConnect:
|
||||
errors["base"] = "cannot_connect"
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"domain": "epson",
|
||||
"name": "epson",
|
||||
"name": "Epson",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/epson",
|
||||
"requirements": ["epson-projector==0.2.3"],
|
||||
|
|
|
@ -17,6 +17,7 @@ from epson_projector.const import (
|
|||
POWER,
|
||||
SOURCE,
|
||||
SOURCE_LIST,
|
||||
STATE_UNAVAILABLE as EPSON_STATE_UNAVAILABLE,
|
||||
TURN_OFF,
|
||||
TURN_ON,
|
||||
VOL_DOWN,
|
||||
|
@ -84,7 +85,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
{vol.Required(ATTR_CMODE): vol.All(cv.string, vol.Any(*CMODE_LIST_SET))},
|
||||
SERVICE_SELECT_CMODE,
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
|
@ -128,7 +128,7 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
|||
self._volume = volume
|
||||
elif power_state == BUSY:
|
||||
self._state = STATE_ON
|
||||
elif power_state == STATE_UNAVAILABLE:
|
||||
elif power_state == EPSON_STATE_UNAVAILABLE:
|
||||
self._state = STATE_UNAVAILABLE
|
||||
else:
|
||||
self._state = STATE_OFF
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
},
|
||||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue