Address post-merge coolmaster config flow code review (#28163)
* Address post-merge code review comments * Use component path for 3rd party lib
This commit is contained in:
parent
43c7b57d1e
commit
0656f0c62b
3 changed files with 13 additions and 18 deletions
|
@ -14,11 +14,10 @@ MODES_SCHEMA = {vol.Required(mode, default=True): bool for mode in AVAILABLE_MOD
|
|||
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str, **MODES_SCHEMA})
|
||||
|
||||
|
||||
async def validate_connection(hass: core.HomeAssistant, host):
|
||||
"""Validate that we can connect to the Coolmaster instance."""
|
||||
async def _validate_connection(hass: core.HomeAssistant, host):
|
||||
cool = CoolMasterNet(host, port=DEFAULT_PORT)
|
||||
devices = await hass.async_add_executor_job(cool.devices)
|
||||
return len(devices) > 0
|
||||
return bool(devices)
|
||||
|
||||
|
||||
class CoolmasterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
@ -50,7 +49,7 @@ class CoolmasterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
host = user_input[CONF_HOST]
|
||||
|
||||
try:
|
||||
result = await validate_connection(self.hass, host)
|
||||
result = await _validate_connection(self.hass, host)
|
||||
if not result:
|
||||
errors["base"] = "no_units"
|
||||
except (ConnectionRefusedError, TimeoutError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue