Skip to content

Commit fabd1b7

Browse files
Merge pull request #327 from vincentwolsink/advanced_options
Hide token source selection under advanced options
2 parents 35852a7 + 44534db commit fabd1b7

4 files changed

Lines changed: 63 additions & 32 deletions

File tree

custom_components/enphase_envoy/config_flow.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
CONF_USERNAME,
1919
)
2020
from homeassistant.core import HomeAssistant, callback
21-
from homeassistant.data_entry_flow import FlowResult
21+
from homeassistant.data_entry_flow import FlowResult, section
2222
from homeassistant.helpers import config_validation as cv
2323
from homeassistant.exceptions import HomeAssistantError
2424
from homeassistant.util.network import is_ipv4_address, is_ipv6_address
@@ -42,6 +42,7 @@
4242
_LOGGER = logging.getLogger(__name__)
4343

4444
ENVOY = "Envoy"
45+
ADVANCED_OPTIONS = "advanced_options"
4546

4647

4748
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> EnvoyReader:
@@ -52,7 +53,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> EnvoyRead
5253
enlighten_pass=data[CONF_PASSWORD],
5354
inverters=False,
5455
enlighten_serial_num=data[CONF_SERIAL],
55-
token_source=data[CONF_TOKEN_SOURCE],
56+
token_source=data[ADVANCED_OPTIONS][CONF_TOKEN_SOURCE],
5657
)
5758

5859
try:
@@ -100,11 +101,17 @@ def _async_generate_schema(self):
100101
schema[vol.Required(CONF_PASSWORD, default=default_data.get(CONF_PASSWORD))] = (
101102
str
102103
)
103-
schema[
104-
vol.Required(
105-
CONF_TOKEN_SOURCE, default=default_data.get(CONF_TOKEN_SOURCE, "entrez")
106-
)
107-
] = vol.In(["entrez", "enlighten"])
104+
schema[vol.Required(ADVANCED_OPTIONS)] = section(
105+
vol.Schema(
106+
{
107+
vol.Required(
108+
CONF_TOKEN_SOURCE,
109+
default=default_data.get(CONF_TOKEN_SOURCE, "entrez"),
110+
): vol.In(["entrez", "enlighten"])
111+
}
112+
),
113+
{"collapsed": True},
114+
)
108115

109116
return vol.Schema(schema)
110117

@@ -215,6 +222,9 @@ async def async_step_user(
215222
data = user_input.copy()
216223
data[CONF_NAME] = self._async_envoy_name()
217224

225+
advanced_options = data.pop(ADVANCED_OPTIONS)
226+
data[CONF_TOKEN_SOURCE] = advanced_options[CONF_TOKEN_SOURCE]
227+
218228
if self._current_entry:
219229
# Remove saved token to prevent it being used after reconfire
220230
store = Store(

custom_components/enphase_envoy/strings.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
"host": "[%key:common::config_flow::data::host%]",
99
"username": "[%key:common::config_flow::data::username%]",
1010
"password": "[%key:common::config_flow::data::password%]",
11-
"serial": "Serial Number",
12-
"token_source": "Login method (token source)"
11+
"serial": "Serial Number"
12+
},
13+
"sections": {
14+
"advanced_options": {
15+
"name": "Advanced options",
16+
"data": {
17+
"token_source": "Login method (token source)"
18+
}
19+
}
1320
}
1421
}
1522
},

custom_components/enphase_envoy/translations/en.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@
1212
"flow_title": "{serial} ({host})",
1313
"step": {
1414
"user": {
15+
"description": "Enter the hostname/ip and serial of your Envoy. Use your Enphase (installer) account credentials.",
1516
"data": {
1617
"host": "Host",
1718
"username": "Username",
1819
"password": "Password",
19-
"serial": "Serial number",
20-
"token_source": "Login method (token source)"
20+
"serial": "Serial number"
2121
},
22-
"description": "Enter the hostname/ip and serial of your Envoy. Use your Enphase (installer) account credentials."
22+
"sections": {
23+
"advanced_options": {
24+
"name": "Advanced options",
25+
"data": {
26+
"token_source": "Login method (token source)"
27+
}
28+
}
29+
}
2330
}
2431
}
2532
},

custom_components/enphase_envoy/translations/nl.json

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
{
22
"config": {
3-
"abort": {
4-
"already_configured": "Apparaat is al geconfigureerd",
5-
"reauth_successful": "Herauthenticatie was succesvol"
6-
},
7-
"error": {
8-
"cannot_connect": "Kan geen verbinding maken met Envoy. Controleer host en serienummer.",
9-
"invalid_auth": "Inloggen mislukt. Controleer Enphase gebruikersnaam/wachtwoord.",
10-
"unknown": "Onverwachte fout"
11-
},
12-
"flow_title": "{serial} ({host})",
13-
"step": {
14-
"user": {
15-
"data": {
16-
"host": "Host",
17-
"username": "Gebruikersnaam",
18-
"password": "Wachtwoord",
19-
"serial": "Serienummer",
20-
"token_source": "Login methode (token bron)"
21-
},
22-
"description": "Voer de hostname/ip en serienummer van je Envoy in. Gebruik je Enphase (installer) account gegevens."
3+
"abort": {
4+
"already_configured": "Apparaat is al geconfigureerd",
5+
"reauth_successful": "Herauthenticatie was succesvol"
6+
},
7+
"error": {
8+
"cannot_connect": "Kan geen verbinding maken met Envoy. Controleer host en serienummer.",
9+
"invalid_auth": "Inloggen mislukt. Controleer Enphase gebruikersnaam/wachtwoord.",
10+
"unknown": "Onverwachte fout"
11+
},
12+
"flow_title": "{serial} ({host})",
13+
"step": {
14+
"user": {
15+
"description": "Voer de hostname/ip en serienummer van je Envoy in. Gebruik je Enphase (installer) account gegevens.",
16+
"data": {
17+
"host": "Host",
18+
"username": "Gebruikersnaam",
19+
"password": "Wachtwoord",
20+
"serial": "Serienummer"
21+
},
22+
"sections": {
23+
"advanced_options": {
24+
"name": "Geavanceerde opties",
25+
"data": {
26+
"token_source": "Login methode (token bron)"
27+
}
2328
}
29+
}
2430
}
31+
}
2532
},
2633
"selector": {
2734
"token_source": {

0 commit comments

Comments
 (0)