Skip to content

Commit

Permalink
Merge pull request #14 from astrandb/Selector
Browse files Browse the repository at this point in the history
Use TextSelector in config_flow
  • Loading branch information
astrandb committed Apr 23, 2023
2 parents fd32e82 + f778d48 commit 235eb41
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
17 changes: 16 additions & 1 deletion custom_components/teracom/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,28 @@
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.components.rest.data import RestData
from homeassistant.helpers.selector import (
TextSelector,
TextSelectorConfig,
TextSelectorType,
)

from .const import DOMAIN, SUPPORTED_MODELS # pylint:disable=unused-import

_LOGGER = logging.getLogger(__name__)

STEP_USER_DATA_SCHEMA = vol.Schema(
{"host": str, vol.Optional("username"): str, vol.Optional("password"): str}
{
vol.Required("host"): TextSelector(
TextSelectorConfig(type=TextSelectorType.TEXT)
),
vol.Optional("username"): TextSelector(
TextSelectorConfig(type=TextSelectorType.TEXT)
),
vol.Optional("password"): TextSelector(
TextSelectorConfig(type=TextSelectorType.PASSWORD)
),
}
)


Expand Down
41 changes: 23 additions & 18 deletions custom_components/teracom/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{
"config": {
"step": {
"user": {
"data": {
"host": "Host",
"password": "Password",
"username": "Username"
}
}
"config": {
"step": {
"user": {
"description": "Enter credentials to access the device",
"data": {
"host": "Host",
"password": "Password",
"username": "Username"
},
"error": {
"cannot_connect": "Failed to connect",
"invalid_auth": "Invalid authentication",
"model_not_supported": "Model {model} not supported",
"unknown": "Unexpected error"
},
"abort": {
"already_configured": "Device is already configured"
"data_description": {
"host": "Hostname or IP address",
"username": "Leave username empty if authentication is disabled"
}
}
},
"error": {
"cannot_connect": "Failed to connect",
"invalid_auth": "Invalid authentication",
"model_not_supported": "Model {model} not supported",
"unknown": "Unexpected error"
},
"abort": {
"already_configured": "Device is already configured"
}
}
}
}

0 comments on commit 235eb41

Please sign in to comment.